Submission #85894

# Submission time Handle Problem Language Result Execution time Memory
85894 2018-11-22T15:20:45 Z igzi Art Exhibition (JOI18_art) C++17
100 / 100
784 ms 224372 KB
#include <bits/stdc++.h>
#define maxN 500005

using namespace std;

long long ans=0,n,i,tmp=LLONG_MIN,s;
pair<long long,long long> a[maxN];

int main()
{
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i].first>>a[i].second;
    sort(a,a+n);
    s=0;
    for(i=0;i<n;i++){
        tmp=max(tmp,a[i].first-s);
        s+=a[i].second;
        ans=max(ans,s-a[i].first+tmp);
    }
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 740 KB Output is correct
8 Correct 2 ms 744 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 2 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 740 KB Output is correct
8 Correct 2 ms 744 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 2 ms 744 KB Output is correct
12 Correct 2 ms 776 KB Output is correct
13 Correct 3 ms 784 KB Output is correct
14 Correct 3 ms 812 KB Output is correct
15 Correct 3 ms 820 KB Output is correct
16 Correct 3 ms 828 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 3 ms 884 KB Output is correct
20 Correct 2 ms 896 KB Output is correct
21 Correct 3 ms 900 KB Output is correct
22 Correct 2 ms 900 KB Output is correct
23 Correct 2 ms 932 KB Output is correct
24 Correct 3 ms 940 KB Output is correct
25 Correct 3 ms 952 KB Output is correct
26 Correct 2 ms 956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 740 KB Output is correct
8 Correct 2 ms 744 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 2 ms 744 KB Output is correct
12 Correct 2 ms 776 KB Output is correct
13 Correct 3 ms 784 KB Output is correct
14 Correct 3 ms 812 KB Output is correct
15 Correct 3 ms 820 KB Output is correct
16 Correct 3 ms 828 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 3 ms 884 KB Output is correct
20 Correct 2 ms 896 KB Output is correct
21 Correct 3 ms 900 KB Output is correct
22 Correct 2 ms 900 KB Output is correct
23 Correct 2 ms 932 KB Output is correct
24 Correct 3 ms 940 KB Output is correct
25 Correct 3 ms 952 KB Output is correct
26 Correct 2 ms 956 KB Output is correct
27 Correct 9 ms 1092 KB Output is correct
28 Correct 13 ms 1348 KB Output is correct
29 Correct 9 ms 1348 KB Output is correct
30 Correct 8 ms 1476 KB Output is correct
31 Correct 8 ms 1652 KB Output is correct
32 Correct 8 ms 1732 KB Output is correct
33 Correct 8 ms 1860 KB Output is correct
34 Correct 8 ms 1988 KB Output is correct
35 Correct 9 ms 2116 KB Output is correct
36 Correct 12 ms 2296 KB Output is correct
37 Correct 9 ms 2424 KB Output is correct
38 Correct 8 ms 2548 KB Output is correct
39 Correct 9 ms 2628 KB Output is correct
40 Correct 8 ms 2756 KB Output is correct
41 Correct 8 ms 2936 KB Output is correct
42 Correct 9 ms 2988 KB Output is correct
43 Correct 8 ms 3168 KB Output is correct
44 Correct 8 ms 3220 KB Output is correct
45 Correct 8 ms 3392 KB Output is correct
46 Correct 8 ms 3524 KB Output is correct
47 Correct 8 ms 3652 KB Output is correct
48 Correct 8 ms 3780 KB Output is correct
49 Correct 13 ms 3956 KB Output is correct
50 Correct 8 ms 4040 KB Output is correct
51 Correct 8 ms 4420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 740 KB Output is correct
8 Correct 2 ms 744 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 2 ms 744 KB Output is correct
12 Correct 2 ms 776 KB Output is correct
13 Correct 3 ms 784 KB Output is correct
14 Correct 3 ms 812 KB Output is correct
15 Correct 3 ms 820 KB Output is correct
16 Correct 3 ms 828 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 3 ms 884 KB Output is correct
20 Correct 2 ms 896 KB Output is correct
21 Correct 3 ms 900 KB Output is correct
22 Correct 2 ms 900 KB Output is correct
23 Correct 2 ms 932 KB Output is correct
24 Correct 3 ms 940 KB Output is correct
25 Correct 3 ms 952 KB Output is correct
26 Correct 2 ms 956 KB Output is correct
27 Correct 9 ms 1092 KB Output is correct
28 Correct 13 ms 1348 KB Output is correct
29 Correct 9 ms 1348 KB Output is correct
30 Correct 8 ms 1476 KB Output is correct
31 Correct 8 ms 1652 KB Output is correct
32 Correct 8 ms 1732 KB Output is correct
33 Correct 8 ms 1860 KB Output is correct
34 Correct 8 ms 1988 KB Output is correct
35 Correct 9 ms 2116 KB Output is correct
36 Correct 12 ms 2296 KB Output is correct
37 Correct 9 ms 2424 KB Output is correct
38 Correct 8 ms 2548 KB Output is correct
39 Correct 9 ms 2628 KB Output is correct
40 Correct 8 ms 2756 KB Output is correct
41 Correct 8 ms 2936 KB Output is correct
42 Correct 9 ms 2988 KB Output is correct
43 Correct 8 ms 3168 KB Output is correct
44 Correct 8 ms 3220 KB Output is correct
45 Correct 8 ms 3392 KB Output is correct
46 Correct 8 ms 3524 KB Output is correct
47 Correct 8 ms 3652 KB Output is correct
48 Correct 8 ms 3780 KB Output is correct
49 Correct 13 ms 3956 KB Output is correct
50 Correct 8 ms 4040 KB Output is correct
51 Correct 8 ms 4420 KB Output is correct
52 Correct 663 ms 24680 KB Output is correct
53 Correct 646 ms 37248 KB Output is correct
54 Correct 666 ms 49908 KB Output is correct
55 Correct 641 ms 62648 KB Output is correct
56 Correct 692 ms 75292 KB Output is correct
57 Correct 706 ms 87980 KB Output is correct
58 Correct 660 ms 100592 KB Output is correct
59 Correct 688 ms 113368 KB Output is correct
60 Correct 691 ms 126080 KB Output is correct
61 Correct 645 ms 138508 KB Output is correct
62 Correct 727 ms 151220 KB Output is correct
63 Correct 677 ms 163880 KB Output is correct
64 Correct 698 ms 176524 KB Output is correct
65 Correct 713 ms 187924 KB Output is correct
66 Correct 784 ms 200632 KB Output is correct
67 Correct 668 ms 213372 KB Output is correct
68 Correct 714 ms 224372 KB Output is correct