Submission #64047

# Submission time Handle Problem Language Result Execution time Memory
64047 2018-08-03T08:51:46 Z patrikpavic2 Art Exhibition (JOI18_art) C++17
100 / 100
782 ms 246636 KB
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>

#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair < ll , ll > pii;

const int N = 5e5 + 500;

vector < pii > v;
set < pii > s;
ll sol = 0, pref[N];
int n;

int main(){
    scanf("%d", &n);
    for(int i = 0;i<n;i++){
        ll x, y;scanf("%lld%lld", &x, &y);
        v.push_back({x, y});
    }
    sort(v.rbegin(), v.rend());
    for(int i = 0;i<n;i++){
        pref[i] = (i ? pref[i - 1] : 0) + v[i].Y;
    }
    for(int i = 0;i<n;i++){
        s.insert({pref[i] + v[i].X, i});
    }
    for(int i = 0;i<n;i++){
        sol = max(sol, (s.rbegin()->X) - (i ? pref[i - 1] : 0) - v[i].X);
        s.erase({pref[i] + v[i].X, i});
    }
    printf("%lld\n", sol);
    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
art.cpp:24:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         ll x, y;scanf("%lld%lld", &x, &y);
                 ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 432 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 432 KB Output is correct
6 Correct 2 ms 432 KB Output is correct
7 Correct 2 ms 432 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 432 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 432 KB Output is correct
6 Correct 2 ms 432 KB Output is correct
7 Correct 2 ms 432 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 4 ms 724 KB Output is correct
18 Correct 3 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 3 ms 736 KB Output is correct
23 Correct 2 ms 736 KB Output is correct
24 Correct 3 ms 736 KB Output is correct
25 Correct 3 ms 736 KB Output is correct
26 Correct 3 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 432 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 432 KB Output is correct
6 Correct 2 ms 432 KB Output is correct
7 Correct 2 ms 432 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 4 ms 724 KB Output is correct
18 Correct 3 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 3 ms 736 KB Output is correct
23 Correct 2 ms 736 KB Output is correct
24 Correct 3 ms 736 KB Output is correct
25 Correct 3 ms 736 KB Output is correct
26 Correct 3 ms 736 KB Output is correct
27 Correct 7 ms 1004 KB Output is correct
28 Correct 6 ms 1004 KB Output is correct
29 Correct 8 ms 1004 KB Output is correct
30 Correct 6 ms 1004 KB Output is correct
31 Correct 7 ms 1004 KB Output is correct
32 Correct 7 ms 1008 KB Output is correct
33 Correct 8 ms 1008 KB Output is correct
34 Correct 8 ms 1008 KB Output is correct
35 Correct 8 ms 1008 KB Output is correct
36 Correct 6 ms 1008 KB Output is correct
37 Correct 6 ms 1008 KB Output is correct
38 Correct 7 ms 1008 KB Output is correct
39 Correct 8 ms 1008 KB Output is correct
40 Correct 8 ms 1008 KB Output is correct
41 Correct 7 ms 1132 KB Output is correct
42 Correct 9 ms 1132 KB Output is correct
43 Correct 8 ms 1132 KB Output is correct
44 Correct 7 ms 1132 KB Output is correct
45 Correct 8 ms 1132 KB Output is correct
46 Correct 8 ms 1132 KB Output is correct
47 Correct 8 ms 1132 KB Output is correct
48 Correct 7 ms 1132 KB Output is correct
49 Correct 7 ms 1132 KB Output is correct
50 Correct 6 ms 1132 KB Output is correct
51 Correct 8 ms 1132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 432 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 432 KB Output is correct
6 Correct 2 ms 432 KB Output is correct
7 Correct 2 ms 432 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 4 ms 724 KB Output is correct
18 Correct 3 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 3 ms 736 KB Output is correct
23 Correct 2 ms 736 KB Output is correct
24 Correct 3 ms 736 KB Output is correct
25 Correct 3 ms 736 KB Output is correct
26 Correct 3 ms 736 KB Output is correct
27 Correct 7 ms 1004 KB Output is correct
28 Correct 6 ms 1004 KB Output is correct
29 Correct 8 ms 1004 KB Output is correct
30 Correct 6 ms 1004 KB Output is correct
31 Correct 7 ms 1004 KB Output is correct
32 Correct 7 ms 1008 KB Output is correct
33 Correct 8 ms 1008 KB Output is correct
34 Correct 8 ms 1008 KB Output is correct
35 Correct 8 ms 1008 KB Output is correct
36 Correct 6 ms 1008 KB Output is correct
37 Correct 6 ms 1008 KB Output is correct
38 Correct 7 ms 1008 KB Output is correct
39 Correct 8 ms 1008 KB Output is correct
40 Correct 8 ms 1008 KB Output is correct
41 Correct 7 ms 1132 KB Output is correct
42 Correct 9 ms 1132 KB Output is correct
43 Correct 8 ms 1132 KB Output is correct
44 Correct 7 ms 1132 KB Output is correct
45 Correct 8 ms 1132 KB Output is correct
46 Correct 8 ms 1132 KB Output is correct
47 Correct 8 ms 1132 KB Output is correct
48 Correct 7 ms 1132 KB Output is correct
49 Correct 7 ms 1132 KB Output is correct
50 Correct 6 ms 1132 KB Output is correct
51 Correct 8 ms 1132 KB Output is correct
52 Correct 469 ms 43660 KB Output is correct
53 Correct 506 ms 56380 KB Output is correct
54 Correct 518 ms 69024 KB Output is correct
55 Correct 501 ms 81900 KB Output is correct
56 Correct 770 ms 94496 KB Output is correct
57 Correct 782 ms 107080 KB Output is correct
58 Correct 652 ms 119752 KB Output is correct
59 Correct 622 ms 132568 KB Output is correct
60 Correct 588 ms 145152 KB Output is correct
61 Correct 512 ms 157744 KB Output is correct
62 Correct 589 ms 170436 KB Output is correct
63 Correct 550 ms 183072 KB Output is correct
64 Correct 611 ms 195804 KB Output is correct
65 Correct 485 ms 208336 KB Output is correct
66 Correct 572 ms 221252 KB Output is correct
67 Correct 688 ms 233700 KB Output is correct
68 Correct 621 ms 246636 KB Output is correct