Submission #66723

# Submission time Handle Problem Language Result Execution time Memory
66723 2018-08-12T07:35:22 Z yusufake Art Exhibition (JOI18_art) C++
100 / 100
346 ms 227284 KB
#include<bits/stdc++.h> 
using namespace std; 

#define mp make_pair 
#define pb push_back 
#define st first 
#define nd second 

typedef long long ll; 
typedef pair < ll , ll > pp; 
const int mod = 1e9 + 7; 
const int N   = 5e5 + 5; 

ll n,i,p,dp,mx,ans;
pp A[N];

int main(){
    scanf("%lld",&n);
    for(i=1;i<=n;i++) scanf("%lld%lld",&A[i].st,&A[i].nd);
    sort(A+1 , A+n+1);
    ans = mx = -(int)(2e18);
    for(i=1;i<=n;i++){
        mx = max(mx , A[i].st - p);
        p += A[i].nd;
        dp = p - A[i].st + mx;
        ans = max(ans , dp);
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
art.cpp:19:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++) scanf("%lld%lld",&A[i].st,&A[i].nd);
                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 3 ms 568 KB Output is correct
5 Correct 3 ms 568 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 3 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 3 ms 664 KB Output is correct
11 Correct 3 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 3 ms 568 KB Output is correct
5 Correct 3 ms 568 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 3 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 3 ms 664 KB Output is correct
11 Correct 3 ms 664 KB Output is correct
12 Correct 3 ms 664 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 3 ms 736 KB Output is correct
15 Correct 3 ms 816 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 4 ms 832 KB Output is correct
18 Correct 3 ms 856 KB Output is correct
19 Correct 3 ms 864 KB Output is correct
20 Correct 3 ms 872 KB Output is correct
21 Correct 4 ms 996 KB Output is correct
22 Correct 2 ms 996 KB Output is correct
23 Correct 2 ms 996 KB Output is correct
24 Correct 4 ms 996 KB Output is correct
25 Correct 3 ms 1040 KB Output is correct
26 Correct 2 ms 1040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 3 ms 568 KB Output is correct
5 Correct 3 ms 568 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 3 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 3 ms 664 KB Output is correct
11 Correct 3 ms 664 KB Output is correct
12 Correct 3 ms 664 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 3 ms 736 KB Output is correct
15 Correct 3 ms 816 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 4 ms 832 KB Output is correct
18 Correct 3 ms 856 KB Output is correct
19 Correct 3 ms 864 KB Output is correct
20 Correct 3 ms 872 KB Output is correct
21 Correct 4 ms 996 KB Output is correct
22 Correct 2 ms 996 KB Output is correct
23 Correct 2 ms 996 KB Output is correct
24 Correct 4 ms 996 KB Output is correct
25 Correct 3 ms 1040 KB Output is correct
26 Correct 2 ms 1040 KB Output is correct
27 Correct 6 ms 1072 KB Output is correct
28 Correct 5 ms 1200 KB Output is correct
29 Correct 6 ms 1328 KB Output is correct
30 Correct 6 ms 1584 KB Output is correct
31 Correct 5 ms 1604 KB Output is correct
32 Correct 6 ms 1736 KB Output is correct
33 Correct 6 ms 1860 KB Output is correct
34 Correct 6 ms 2036 KB Output is correct
35 Correct 7 ms 2116 KB Output is correct
36 Correct 5 ms 2244 KB Output is correct
37 Correct 6 ms 2372 KB Output is correct
38 Correct 6 ms 2552 KB Output is correct
39 Correct 7 ms 2732 KB Output is correct
40 Correct 5 ms 2756 KB Output is correct
41 Correct 7 ms 2884 KB Output is correct
42 Correct 5 ms 3008 KB Output is correct
43 Correct 6 ms 3120 KB Output is correct
44 Correct 7 ms 3264 KB Output is correct
45 Correct 5 ms 3440 KB Output is correct
46 Correct 6 ms 3568 KB Output is correct
47 Correct 7 ms 3648 KB Output is correct
48 Correct 6 ms 3776 KB Output is correct
49 Correct 6 ms 3904 KB Output is correct
50 Correct 7 ms 4032 KB Output is correct
51 Correct 6 ms 4160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 3 ms 568 KB Output is correct
5 Correct 3 ms 568 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 3 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 3 ms 664 KB Output is correct
11 Correct 3 ms 664 KB Output is correct
12 Correct 3 ms 664 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 3 ms 736 KB Output is correct
15 Correct 3 ms 816 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 4 ms 832 KB Output is correct
18 Correct 3 ms 856 KB Output is correct
19 Correct 3 ms 864 KB Output is correct
20 Correct 3 ms 872 KB Output is correct
21 Correct 4 ms 996 KB Output is correct
22 Correct 2 ms 996 KB Output is correct
23 Correct 2 ms 996 KB Output is correct
24 Correct 4 ms 996 KB Output is correct
25 Correct 3 ms 1040 KB Output is correct
26 Correct 2 ms 1040 KB Output is correct
27 Correct 6 ms 1072 KB Output is correct
28 Correct 5 ms 1200 KB Output is correct
29 Correct 6 ms 1328 KB Output is correct
30 Correct 6 ms 1584 KB Output is correct
31 Correct 5 ms 1604 KB Output is correct
32 Correct 6 ms 1736 KB Output is correct
33 Correct 6 ms 1860 KB Output is correct
34 Correct 6 ms 2036 KB Output is correct
35 Correct 7 ms 2116 KB Output is correct
36 Correct 5 ms 2244 KB Output is correct
37 Correct 6 ms 2372 KB Output is correct
38 Correct 6 ms 2552 KB Output is correct
39 Correct 7 ms 2732 KB Output is correct
40 Correct 5 ms 2756 KB Output is correct
41 Correct 7 ms 2884 KB Output is correct
42 Correct 5 ms 3008 KB Output is correct
43 Correct 6 ms 3120 KB Output is correct
44 Correct 7 ms 3264 KB Output is correct
45 Correct 5 ms 3440 KB Output is correct
46 Correct 6 ms 3568 KB Output is correct
47 Correct 7 ms 3648 KB Output is correct
48 Correct 6 ms 3776 KB Output is correct
49 Correct 6 ms 3904 KB Output is correct
50 Correct 7 ms 4032 KB Output is correct
51 Correct 6 ms 4160 KB Output is correct
52 Correct 298 ms 24596 KB Output is correct
53 Correct 337 ms 37260 KB Output is correct
54 Correct 262 ms 49920 KB Output is correct
55 Correct 284 ms 62704 KB Output is correct
56 Correct 325 ms 75240 KB Output is correct
57 Correct 292 ms 87916 KB Output is correct
58 Correct 292 ms 100596 KB Output is correct
59 Correct 282 ms 113284 KB Output is correct
60 Correct 285 ms 126076 KB Output is correct
61 Correct 286 ms 138552 KB Output is correct
62 Correct 272 ms 151164 KB Output is correct
63 Correct 289 ms 163856 KB Output is correct
64 Correct 309 ms 176516 KB Output is correct
65 Correct 306 ms 189228 KB Output is correct
66 Correct 307 ms 201800 KB Output is correct
67 Correct 287 ms 214480 KB Output is correct
68 Correct 346 ms 227284 KB Output is correct