답안 #42090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42090 2018-02-22T11:24:34 Z nonocut Art Exhibition (JOI18_art) C++14
100 / 100
280 ms 87280 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define X first
#define Y second
const int maxn = 5e5 + 5;
const ll inf = 1e18;
int n,m;
pii p[maxn], a[maxn];
int main() {
    int i,j;
    ll ans = 0;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%lld%lld",&p[i].X,&p[i].Y);
    sort(p,p+n);
    for(i=0;i<n;i++) {
        if(p[i].X!=p[i+1].X) a[m++] = p[i];
        else p[i+1].Y += p[i].Y;
    }
    ll sum = 0, mx = -inf;
    for(i=0;i<m;i++) {
        mx = max(mx, a[i].X - sum);
        sum += a[i].Y;
        ans = max(ans, sum - a[i].X + mx);
    }
    printf("%lld",ans);
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:12:11: warning: unused variable 'j' [-Wunused-variable]
     int i,j;
           ^
art.cpp:14:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
art.cpp:15:55: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=0;i<n;i++) scanf("%lld%lld",&p[i].X,&p[i].Y);
                                                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 684 KB Output is correct
8 Correct 1 ms 684 KB Output is correct
9 Correct 2 ms 684 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 2 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 684 KB Output is correct
8 Correct 1 ms 684 KB Output is correct
9 Correct 2 ms 684 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 2 ms 748 KB Output is correct
12 Correct 2 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 2 ms 748 KB Output is correct
15 Correct 2 ms 748 KB Output is correct
16 Correct 2 ms 748 KB Output is correct
17 Correct 2 ms 748 KB Output is correct
18 Correct 2 ms 748 KB Output is correct
19 Correct 2 ms 748 KB Output is correct
20 Correct 2 ms 748 KB Output is correct
21 Correct 2 ms 748 KB Output is correct
22 Correct 2 ms 748 KB Output is correct
23 Correct 2 ms 748 KB Output is correct
24 Correct 2 ms 756 KB Output is correct
25 Correct 2 ms 764 KB Output is correct
26 Correct 2 ms 772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 684 KB Output is correct
8 Correct 1 ms 684 KB Output is correct
9 Correct 2 ms 684 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 2 ms 748 KB Output is correct
12 Correct 2 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 2 ms 748 KB Output is correct
15 Correct 2 ms 748 KB Output is correct
16 Correct 2 ms 748 KB Output is correct
17 Correct 2 ms 748 KB Output is correct
18 Correct 2 ms 748 KB Output is correct
19 Correct 2 ms 748 KB Output is correct
20 Correct 2 ms 748 KB Output is correct
21 Correct 2 ms 748 KB Output is correct
22 Correct 2 ms 748 KB Output is correct
23 Correct 2 ms 748 KB Output is correct
24 Correct 2 ms 756 KB Output is correct
25 Correct 2 ms 764 KB Output is correct
26 Correct 2 ms 772 KB Output is correct
27 Correct 6 ms 912 KB Output is correct
28 Correct 6 ms 1040 KB Output is correct
29 Correct 4 ms 1228 KB Output is correct
30 Correct 4 ms 1300 KB Output is correct
31 Correct 4 ms 1484 KB Output is correct
32 Correct 4 ms 1612 KB Output is correct
33 Correct 7 ms 1740 KB Output is correct
34 Correct 5 ms 1868 KB Output is correct
35 Correct 4 ms 1996 KB Output is correct
36 Correct 4 ms 2124 KB Output is correct
37 Correct 4 ms 2252 KB Output is correct
38 Correct 4 ms 2468 KB Output is correct
39 Correct 5 ms 2516 KB Output is correct
40 Correct 4 ms 2636 KB Output is correct
41 Correct 4 ms 2764 KB Output is correct
42 Correct 4 ms 2888 KB Output is correct
43 Correct 4 ms 3016 KB Output is correct
44 Correct 4 ms 3096 KB Output is correct
45 Correct 4 ms 3272 KB Output is correct
46 Correct 4 ms 3368 KB Output is correct
47 Correct 4 ms 3588 KB Output is correct
48 Correct 4 ms 3716 KB Output is correct
49 Correct 4 ms 3876 KB Output is correct
50 Correct 4 ms 3912 KB Output is correct
51 Correct 4 ms 4004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 684 KB Output is correct
8 Correct 1 ms 684 KB Output is correct
9 Correct 2 ms 684 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 2 ms 748 KB Output is correct
12 Correct 2 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 2 ms 748 KB Output is correct
15 Correct 2 ms 748 KB Output is correct
16 Correct 2 ms 748 KB Output is correct
17 Correct 2 ms 748 KB Output is correct
18 Correct 2 ms 748 KB Output is correct
19 Correct 2 ms 748 KB Output is correct
20 Correct 2 ms 748 KB Output is correct
21 Correct 2 ms 748 KB Output is correct
22 Correct 2 ms 748 KB Output is correct
23 Correct 2 ms 748 KB Output is correct
24 Correct 2 ms 756 KB Output is correct
25 Correct 2 ms 764 KB Output is correct
26 Correct 2 ms 772 KB Output is correct
27 Correct 6 ms 912 KB Output is correct
28 Correct 6 ms 1040 KB Output is correct
29 Correct 4 ms 1228 KB Output is correct
30 Correct 4 ms 1300 KB Output is correct
31 Correct 4 ms 1484 KB Output is correct
32 Correct 4 ms 1612 KB Output is correct
33 Correct 7 ms 1740 KB Output is correct
34 Correct 5 ms 1868 KB Output is correct
35 Correct 4 ms 1996 KB Output is correct
36 Correct 4 ms 2124 KB Output is correct
37 Correct 4 ms 2252 KB Output is correct
38 Correct 4 ms 2468 KB Output is correct
39 Correct 5 ms 2516 KB Output is correct
40 Correct 4 ms 2636 KB Output is correct
41 Correct 4 ms 2764 KB Output is correct
42 Correct 4 ms 2888 KB Output is correct
43 Correct 4 ms 3016 KB Output is correct
44 Correct 4 ms 3096 KB Output is correct
45 Correct 4 ms 3272 KB Output is correct
46 Correct 4 ms 3368 KB Output is correct
47 Correct 4 ms 3588 KB Output is correct
48 Correct 4 ms 3716 KB Output is correct
49 Correct 4 ms 3876 KB Output is correct
50 Correct 4 ms 3912 KB Output is correct
51 Correct 4 ms 4004 KB Output is correct
52 Correct 279 ms 32328 KB Output is correct
53 Correct 261 ms 44832 KB Output is correct
54 Correct 255 ms 57304 KB Output is correct
55 Correct 280 ms 70240 KB Output is correct
56 Correct 274 ms 82728 KB Output is correct
57 Correct 262 ms 87252 KB Output is correct
58 Correct 265 ms 87268 KB Output is correct
59 Correct 253 ms 87268 KB Output is correct
60 Correct 263 ms 87268 KB Output is correct
61 Correct 260 ms 87268 KB Output is correct
62 Correct 263 ms 87280 KB Output is correct
63 Correct 260 ms 87280 KB Output is correct
64 Correct 262 ms 87280 KB Output is correct
65 Correct 255 ms 87280 KB Output is correct
66 Correct 270 ms 87280 KB Output is correct
67 Correct 267 ms 87280 KB Output is correct
68 Correct 259 ms 87280 KB Output is correct