답안 #71443

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71443 2018-08-24T16:30:04 Z win11905 Art Exhibition (JOI18_art) C++11
100 / 100
365 ms 10616 KB
#include <bits/stdc++.h>
using namespace std;

#define long long long
#define pll pair<long, long>
#define x first
#define y second

int n;
long pref, ans, lhs = -1e18;

int main() {
    scanf("%d", &n);
    vector<pll> V; V.reserve(n+1);
    for(int i = 0; i < n; ++i) {
        long a, b; scanf("%lld %lld", &a, &b);
        V.emplace_back(a, b);
    }
    sort(V.begin(), V.end());
    for(int i = 0; i < n; ++i) {
        long a, b; tie(a, b) = V[i];
        lhs = max(lhs, a - pref);
        pref += b;
        ans = max(ans, pref - a + lhs);
    }
    printf("%lld\n", ans);
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
art.cpp:16:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         long a, b; scanf("%lld %lld", &a, &b);
                    ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 3 ms 472 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
7 Correct 3 ms 520 KB Output is correct
8 Correct 3 ms 520 KB Output is correct
9 Correct 3 ms 520 KB Output is correct
10 Correct 5 ms 520 KB Output is correct
11 Correct 2 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 3 ms 472 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
7 Correct 3 ms 520 KB Output is correct
8 Correct 3 ms 520 KB Output is correct
9 Correct 3 ms 520 KB Output is correct
10 Correct 5 ms 520 KB Output is correct
11 Correct 2 ms 520 KB Output is correct
12 Correct 3 ms 568 KB Output is correct
13 Correct 4 ms 660 KB Output is correct
14 Correct 3 ms 660 KB Output is correct
15 Correct 3 ms 668 KB Output is correct
16 Correct 3 ms 676 KB Output is correct
17 Correct 4 ms 676 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 2 ms 676 KB Output is correct
20 Correct 3 ms 716 KB Output is correct
21 Correct 2 ms 724 KB Output is correct
22 Correct 3 ms 728 KB Output is correct
23 Correct 4 ms 728 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 3 ms 748 KB Output is correct
26 Correct 4 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 3 ms 472 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
7 Correct 3 ms 520 KB Output is correct
8 Correct 3 ms 520 KB Output is correct
9 Correct 3 ms 520 KB Output is correct
10 Correct 5 ms 520 KB Output is correct
11 Correct 2 ms 520 KB Output is correct
12 Correct 3 ms 568 KB Output is correct
13 Correct 4 ms 660 KB Output is correct
14 Correct 3 ms 660 KB Output is correct
15 Correct 3 ms 668 KB Output is correct
16 Correct 3 ms 676 KB Output is correct
17 Correct 4 ms 676 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 2 ms 676 KB Output is correct
20 Correct 3 ms 716 KB Output is correct
21 Correct 2 ms 724 KB Output is correct
22 Correct 3 ms 728 KB Output is correct
23 Correct 4 ms 728 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 3 ms 748 KB Output is correct
26 Correct 4 ms 748 KB Output is correct
27 Correct 8 ms 900 KB Output is correct
28 Correct 8 ms 1028 KB Output is correct
29 Correct 5 ms 1284 KB Output is correct
30 Correct 5 ms 1304 KB Output is correct
31 Correct 6 ms 1428 KB Output is correct
32 Correct 8 ms 1552 KB Output is correct
33 Correct 7 ms 1684 KB Output is correct
34 Correct 6 ms 1812 KB Output is correct
35 Correct 7 ms 1936 KB Output is correct
36 Correct 6 ms 2072 KB Output is correct
37 Correct 5 ms 2196 KB Output is correct
38 Correct 6 ms 2324 KB Output is correct
39 Correct 6 ms 2504 KB Output is correct
40 Correct 6 ms 2684 KB Output is correct
41 Correct 8 ms 2688 KB Output is correct
42 Correct 8 ms 2744 KB Output is correct
43 Correct 5 ms 2744 KB Output is correct
44 Correct 5 ms 2744 KB Output is correct
45 Correct 7 ms 2744 KB Output is correct
46 Correct 7 ms 2744 KB Output is correct
47 Correct 6 ms 2744 KB Output is correct
48 Correct 6 ms 2744 KB Output is correct
49 Correct 8 ms 2744 KB Output is correct
50 Correct 8 ms 2744 KB Output is correct
51 Correct 8 ms 2744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 3 ms 472 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
7 Correct 3 ms 520 KB Output is correct
8 Correct 3 ms 520 KB Output is correct
9 Correct 3 ms 520 KB Output is correct
10 Correct 5 ms 520 KB Output is correct
11 Correct 2 ms 520 KB Output is correct
12 Correct 3 ms 568 KB Output is correct
13 Correct 4 ms 660 KB Output is correct
14 Correct 3 ms 660 KB Output is correct
15 Correct 3 ms 668 KB Output is correct
16 Correct 3 ms 676 KB Output is correct
17 Correct 4 ms 676 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 2 ms 676 KB Output is correct
20 Correct 3 ms 716 KB Output is correct
21 Correct 2 ms 724 KB Output is correct
22 Correct 3 ms 728 KB Output is correct
23 Correct 4 ms 728 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 3 ms 748 KB Output is correct
26 Correct 4 ms 748 KB Output is correct
27 Correct 8 ms 900 KB Output is correct
28 Correct 8 ms 1028 KB Output is correct
29 Correct 5 ms 1284 KB Output is correct
30 Correct 5 ms 1304 KB Output is correct
31 Correct 6 ms 1428 KB Output is correct
32 Correct 8 ms 1552 KB Output is correct
33 Correct 7 ms 1684 KB Output is correct
34 Correct 6 ms 1812 KB Output is correct
35 Correct 7 ms 1936 KB Output is correct
36 Correct 6 ms 2072 KB Output is correct
37 Correct 5 ms 2196 KB Output is correct
38 Correct 6 ms 2324 KB Output is correct
39 Correct 6 ms 2504 KB Output is correct
40 Correct 6 ms 2684 KB Output is correct
41 Correct 8 ms 2688 KB Output is correct
42 Correct 8 ms 2744 KB Output is correct
43 Correct 5 ms 2744 KB Output is correct
44 Correct 5 ms 2744 KB Output is correct
45 Correct 7 ms 2744 KB Output is correct
46 Correct 7 ms 2744 KB Output is correct
47 Correct 6 ms 2744 KB Output is correct
48 Correct 6 ms 2744 KB Output is correct
49 Correct 8 ms 2744 KB Output is correct
50 Correct 8 ms 2744 KB Output is correct
51 Correct 8 ms 2744 KB Output is correct
52 Correct 321 ms 10568 KB Output is correct
53 Correct 298 ms 10568 KB Output is correct
54 Correct 327 ms 10568 KB Output is correct
55 Correct 326 ms 10568 KB Output is correct
56 Correct 340 ms 10568 KB Output is correct
57 Correct 329 ms 10568 KB Output is correct
58 Correct 300 ms 10568 KB Output is correct
59 Correct 365 ms 10568 KB Output is correct
60 Correct 362 ms 10568 KB Output is correct
61 Correct 362 ms 10568 KB Output is correct
62 Correct 292 ms 10616 KB Output is correct
63 Correct 365 ms 10616 KB Output is correct
64 Correct 279 ms 10616 KB Output is correct
65 Correct 317 ms 10616 KB Output is correct
66 Correct 353 ms 10616 KB Output is correct
67 Correct 316 ms 10616 KB Output is correct
68 Correct 297 ms 10616 KB Output is correct