Submission #64046

# Submission time Handle Problem Language Result Execution time Memory
64046 2018-08-03T08:50:59 Z patrikpavic2 Art Exhibition (JOI18_art) C++17
50 / 100
370 ms 34188 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 = 1e5 + 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 252 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 516 KB Output is correct
6 Correct 3 ms 536 KB Output is correct
7 Correct 3 ms 536 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 3 ms 576 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 4 ms 576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 252 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 516 KB Output is correct
6 Correct 3 ms 536 KB Output is correct
7 Correct 3 ms 536 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 3 ms 576 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 4 ms 576 KB Output is correct
12 Correct 3 ms 664 KB Output is correct
13 Correct 3 ms 672 KB Output is correct
14 Correct 4 ms 680 KB Output is correct
15 Correct 3 ms 804 KB Output is correct
16 Correct 3 ms 804 KB Output is correct
17 Correct 3 ms 804 KB Output is correct
18 Correct 3 ms 804 KB Output is correct
19 Correct 3 ms 804 KB Output is correct
20 Correct 4 ms 804 KB Output is correct
21 Correct 3 ms 804 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 2 ms 860 KB Output is correct
24 Correct 3 ms 860 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 252 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 516 KB Output is correct
6 Correct 3 ms 536 KB Output is correct
7 Correct 3 ms 536 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 3 ms 576 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 4 ms 576 KB Output is correct
12 Correct 3 ms 664 KB Output is correct
13 Correct 3 ms 672 KB Output is correct
14 Correct 4 ms 680 KB Output is correct
15 Correct 3 ms 804 KB Output is correct
16 Correct 3 ms 804 KB Output is correct
17 Correct 3 ms 804 KB Output is correct
18 Correct 3 ms 804 KB Output is correct
19 Correct 3 ms 804 KB Output is correct
20 Correct 4 ms 804 KB Output is correct
21 Correct 3 ms 804 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 2 ms 860 KB Output is correct
24 Correct 3 ms 860 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 7 ms 1296 KB Output is correct
28 Correct 8 ms 1424 KB Output is correct
29 Correct 7 ms 1552 KB Output is correct
30 Correct 6 ms 1812 KB Output is correct
31 Correct 9 ms 1924 KB Output is correct
32 Correct 7 ms 2024 KB Output is correct
33 Correct 7 ms 2152 KB Output is correct
34 Correct 8 ms 2152 KB Output is correct
35 Correct 7 ms 2368 KB Output is correct
36 Correct 7 ms 2412 KB Output is correct
37 Correct 8 ms 2576 KB Output is correct
38 Correct 9 ms 2672 KB Output is correct
39 Correct 7 ms 2836 KB Output is correct
40 Correct 7 ms 3056 KB Output is correct
41 Correct 7 ms 3092 KB Output is correct
42 Correct 8 ms 3216 KB Output is correct
43 Correct 9 ms 3344 KB Output is correct
44 Correct 8 ms 3472 KB Output is correct
45 Correct 8 ms 3600 KB Output is correct
46 Correct 7 ms 3728 KB Output is correct
47 Correct 6 ms 3856 KB Output is correct
48 Correct 9 ms 3984 KB Output is correct
49 Correct 6 ms 4112 KB Output is correct
50 Correct 6 ms 4240 KB Output is correct
51 Correct 6 ms 4496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 252 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 516 KB Output is correct
6 Correct 3 ms 536 KB Output is correct
7 Correct 3 ms 536 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 3 ms 576 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 4 ms 576 KB Output is correct
12 Correct 3 ms 664 KB Output is correct
13 Correct 3 ms 672 KB Output is correct
14 Correct 4 ms 680 KB Output is correct
15 Correct 3 ms 804 KB Output is correct
16 Correct 3 ms 804 KB Output is correct
17 Correct 3 ms 804 KB Output is correct
18 Correct 3 ms 804 KB Output is correct
19 Correct 3 ms 804 KB Output is correct
20 Correct 4 ms 804 KB Output is correct
21 Correct 3 ms 804 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 2 ms 860 KB Output is correct
24 Correct 3 ms 860 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 7 ms 1296 KB Output is correct
28 Correct 8 ms 1424 KB Output is correct
29 Correct 7 ms 1552 KB Output is correct
30 Correct 6 ms 1812 KB Output is correct
31 Correct 9 ms 1924 KB Output is correct
32 Correct 7 ms 2024 KB Output is correct
33 Correct 7 ms 2152 KB Output is correct
34 Correct 8 ms 2152 KB Output is correct
35 Correct 7 ms 2368 KB Output is correct
36 Correct 7 ms 2412 KB Output is correct
37 Correct 8 ms 2576 KB Output is correct
38 Correct 9 ms 2672 KB Output is correct
39 Correct 7 ms 2836 KB Output is correct
40 Correct 7 ms 3056 KB Output is correct
41 Correct 7 ms 3092 KB Output is correct
42 Correct 8 ms 3216 KB Output is correct
43 Correct 9 ms 3344 KB Output is correct
44 Correct 8 ms 3472 KB Output is correct
45 Correct 8 ms 3600 KB Output is correct
46 Correct 7 ms 3728 KB Output is correct
47 Correct 6 ms 3856 KB Output is correct
48 Correct 9 ms 3984 KB Output is correct
49 Correct 6 ms 4112 KB Output is correct
50 Correct 6 ms 4240 KB Output is correct
51 Correct 6 ms 4496 KB Output is correct
52 Runtime error 370 ms 34188 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Halted 0 ms 0 KB -