답안 #357586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
357586 2021-01-24T07:54:33 Z cute_hater Art Exhibition (JOI18_art) C++17
100 / 100
480 ms 37484 KB
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>


#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 5e5 + 7;

pi t[4 * N];

void change(int v, int l, int r, int pos, int val) {
    if (l == r) {
        t[v] = { val, val };
        return;
    }
    int m = l + r >> 1;
    if (m >= pos)
        change(2 * v + 1, l, m, pos, val);
    else
        change(2 * v + 2, m + 1, r, pos, val);
    t[v] = { t[2 * v + 1].F + t[2 * v + 2].F, max(t[2 * v + 1].S, t[2 * v + 1].F + t[2 * v + 2].S) };
}

void solve() {
    int n; cin >> n;
    vector <pi> p(n);
    loop(i, n)
        cin >> p[i].F >> p[i].S;
    sort(all(p));
    change(0, 0, n - 1, 0, p[0].S);
    loop1(i, n - 1)
        change(0, 0, n - 1, i, p[i].S - (p[i].F - p[i - 1].F));
    int ans = p.back().S;
    loop(i, n - 1) {
        ans = max(ans, t[0].S);
        change(0, 0, n - 1, i, 0);
        change(0, 0, n - 1, i + 1, p[i + 1].S);
    }
    cout << ans;
}

signed main() {
    //freopen("b2.txt", "r", stdin);
    //freopen("ans9.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Compilation message

art.cpp: In function 'void change(ll, ll, ll, ll, ll)':
art.cpp:61:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   61 |     int m = l + r >> 1;
      |             ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 4 ms 748 KB Output is correct
28 Correct 4 ms 748 KB Output is correct
29 Correct 4 ms 748 KB Output is correct
30 Correct 4 ms 748 KB Output is correct
31 Correct 4 ms 748 KB Output is correct
32 Correct 4 ms 748 KB Output is correct
33 Correct 4 ms 764 KB Output is correct
34 Correct 4 ms 748 KB Output is correct
35 Correct 5 ms 748 KB Output is correct
36 Correct 4 ms 748 KB Output is correct
37 Correct 4 ms 748 KB Output is correct
38 Correct 4 ms 748 KB Output is correct
39 Correct 4 ms 748 KB Output is correct
40 Correct 4 ms 748 KB Output is correct
41 Correct 4 ms 748 KB Output is correct
42 Correct 4 ms 748 KB Output is correct
43 Correct 5 ms 748 KB Output is correct
44 Correct 4 ms 748 KB Output is correct
45 Correct 4 ms 748 KB Output is correct
46 Correct 4 ms 748 KB Output is correct
47 Correct 4 ms 748 KB Output is correct
48 Correct 5 ms 748 KB Output is correct
49 Correct 4 ms 748 KB Output is correct
50 Correct 4 ms 748 KB Output is correct
51 Correct 4 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 4 ms 748 KB Output is correct
28 Correct 4 ms 748 KB Output is correct
29 Correct 4 ms 748 KB Output is correct
30 Correct 4 ms 748 KB Output is correct
31 Correct 4 ms 748 KB Output is correct
32 Correct 4 ms 748 KB Output is correct
33 Correct 4 ms 764 KB Output is correct
34 Correct 4 ms 748 KB Output is correct
35 Correct 5 ms 748 KB Output is correct
36 Correct 4 ms 748 KB Output is correct
37 Correct 4 ms 748 KB Output is correct
38 Correct 4 ms 748 KB Output is correct
39 Correct 4 ms 748 KB Output is correct
40 Correct 4 ms 748 KB Output is correct
41 Correct 4 ms 748 KB Output is correct
42 Correct 4 ms 748 KB Output is correct
43 Correct 5 ms 748 KB Output is correct
44 Correct 4 ms 748 KB Output is correct
45 Correct 4 ms 748 KB Output is correct
46 Correct 4 ms 748 KB Output is correct
47 Correct 4 ms 748 KB Output is correct
48 Correct 5 ms 748 KB Output is correct
49 Correct 4 ms 748 KB Output is correct
50 Correct 4 ms 748 KB Output is correct
51 Correct 4 ms 748 KB Output is correct
52 Correct 447 ms 37228 KB Output is correct
53 Correct 458 ms 37228 KB Output is correct
54 Correct 452 ms 37228 KB Output is correct
55 Correct 474 ms 37336 KB Output is correct
56 Correct 452 ms 37356 KB Output is correct
57 Correct 467 ms 37288 KB Output is correct
58 Correct 456 ms 37356 KB Output is correct
59 Correct 454 ms 37228 KB Output is correct
60 Correct 460 ms 37356 KB Output is correct
61 Correct 480 ms 37228 KB Output is correct
62 Correct 473 ms 37356 KB Output is correct
63 Correct 468 ms 37228 KB Output is correct
64 Correct 472 ms 37228 KB Output is correct
65 Correct 471 ms 37484 KB Output is correct
66 Correct 461 ms 37228 KB Output is correct
67 Correct 462 ms 37356 KB Output is correct
68 Correct 466 ms 37288 KB Output is correct