답안 #1049938

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1049938 2024-08-09T06:14:22 Z vjudge1 Art Exhibition (JOI18_art) C++17
100 / 100
349 ms 28624 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
int main() {
    int n;
    cin >> n;
    pair<long long, long long> a[n];long long b[n], c[n], mx=-INT64_MAX, mj=0, mnx;
    for(int i=0; i<n; i++){
        cin >> a[i].f >> a[i].s;
    }
    sort(a, a+n);
    b[0]=a[0].s-a[0].f;
    for(int i=1; i<n ;i++){
        b[i]=b[i-1]-a[i].f+a[i].s+a[i-1].f;
    }
    c[0]=a[0].f;
    for(int i=1; i<n;i++){
        c[i]=c[i-1]-a[i-1].f+a[i].f-a[i-1].s;
    }
    for(int i=1; i<n;i++){
        c[i]=max(c[i-1],c[i]);
    }
    for(int i=0; i<n; i++){
        mx=max(mx, c[i]+b[i]);
    }
    cout << mx;
    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:8:74: warning: unused variable 'mj' [-Wunused-variable]
    8 |     pair<long long, long long> a[n];long long b[n], c[n], mx=-INT64_MAX, mj=0, mnx;
      |                                                                          ^~
art.cpp:8:80: warning: unused variable 'mnx' [-Wunused-variable]
    8 |     pair<long long, long long> a[n];long long b[n], c[n], mx=-INT64_MAX, mj=0, mnx;
      |                                                                                ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 6 ms 628 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 3 ms 704 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 4 ms 604 KB Output is correct
35 Correct 6 ms 600 KB Output is correct
36 Correct 4 ms 704 KB Output is correct
37 Correct 4 ms 604 KB Output is correct
38 Correct 5 ms 696 KB Output is correct
39 Correct 3 ms 600 KB Output is correct
40 Correct 3 ms 708 KB Output is correct
41 Correct 5 ms 604 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 5 ms 604 KB Output is correct
44 Correct 3 ms 604 KB Output is correct
45 Correct 3 ms 708 KB Output is correct
46 Correct 5 ms 604 KB Output is correct
47 Correct 5 ms 604 KB Output is correct
48 Correct 5 ms 692 KB Output is correct
49 Correct 5 ms 604 KB Output is correct
50 Correct 3 ms 604 KB Output is correct
51 Correct 4 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 6 ms 628 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 3 ms 704 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 4 ms 604 KB Output is correct
35 Correct 6 ms 600 KB Output is correct
36 Correct 4 ms 704 KB Output is correct
37 Correct 4 ms 604 KB Output is correct
38 Correct 5 ms 696 KB Output is correct
39 Correct 3 ms 600 KB Output is correct
40 Correct 3 ms 708 KB Output is correct
41 Correct 5 ms 604 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 5 ms 604 KB Output is correct
44 Correct 3 ms 604 KB Output is correct
45 Correct 3 ms 708 KB Output is correct
46 Correct 5 ms 604 KB Output is correct
47 Correct 5 ms 604 KB Output is correct
48 Correct 5 ms 692 KB Output is correct
49 Correct 5 ms 604 KB Output is correct
50 Correct 3 ms 604 KB Output is correct
51 Correct 4 ms 604 KB Output is correct
52 Correct 304 ms 28600 KB Output is correct
53 Correct 272 ms 28600 KB Output is correct
54 Correct 297 ms 28500 KB Output is correct
55 Correct 306 ms 28624 KB Output is correct
56 Correct 278 ms 28608 KB Output is correct
57 Correct 295 ms 28500 KB Output is correct
58 Correct 274 ms 28500 KB Output is correct
59 Correct 293 ms 28600 KB Output is correct
60 Correct 311 ms 28580 KB Output is correct
61 Correct 288 ms 28500 KB Output is correct
62 Correct 274 ms 28496 KB Output is correct
63 Correct 272 ms 28464 KB Output is correct
64 Correct 349 ms 28456 KB Output is correct
65 Correct 281 ms 28496 KB Output is correct
66 Correct 343 ms 28472 KB Output is correct
67 Correct 294 ms 28500 KB Output is correct
68 Correct 300 ms 28600 KB Output is correct