답안 #699683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699683 2023-02-17T17:57:24 Z Mohamed_Kachef06 Art Exhibition (JOI18_art) C++17
100 / 100
532 ms 13024 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define A first
#define B second
signed main(){
   int n;
   cin >> n;
   pair<int , int> p[n+1];
   for (int i = 1 ; i<=n ; i++){
      int a , b;
      cin >> a >> b;
      p[i] = {a , b};
   }
   sort(p , p+n+1);
   for (int i = 1 ; i<=n ; i++){
      p[i].B += p[i-1].B;
   }
   int mn[n+1] = {};
   for (int i = 0 ; i<=n ; i++) mn[i] = 1e18;
   for (int i = 1 ; i<=n ; i++){
     mn[i] = min(p[i-1].B - p[i].A , mn[i-1]);
   }
    int ans = -1e18;
    for (int i = 1; i<=n ; i++){
        if ((p[i].B - p[i].A) - mn[i] > ans ) ans = (p[i].B - p[i].A) - mn[i] ;
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
27 Correct 6 ms 480 KB Output is correct
28 Correct 5 ms 468 KB Output is correct
29 Correct 7 ms 436 KB Output is correct
30 Correct 6 ms 484 KB Output is correct
31 Correct 5 ms 440 KB Output is correct
32 Correct 5 ms 468 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 6 ms 468 KB Output is correct
35 Correct 6 ms 440 KB Output is correct
36 Correct 6 ms 468 KB Output is correct
37 Correct 6 ms 468 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 6 ms 476 KB Output is correct
40 Correct 5 ms 468 KB Output is correct
41 Correct 6 ms 440 KB Output is correct
42 Correct 6 ms 496 KB Output is correct
43 Correct 5 ms 436 KB Output is correct
44 Correct 6 ms 468 KB Output is correct
45 Correct 6 ms 468 KB Output is correct
46 Correct 5 ms 468 KB Output is correct
47 Correct 6 ms 496 KB Output is correct
48 Correct 5 ms 440 KB Output is correct
49 Correct 7 ms 500 KB Output is correct
50 Correct 7 ms 484 KB Output is correct
51 Correct 5 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
27 Correct 6 ms 480 KB Output is correct
28 Correct 5 ms 468 KB Output is correct
29 Correct 7 ms 436 KB Output is correct
30 Correct 6 ms 484 KB Output is correct
31 Correct 5 ms 440 KB Output is correct
32 Correct 5 ms 468 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 6 ms 468 KB Output is correct
35 Correct 6 ms 440 KB Output is correct
36 Correct 6 ms 468 KB Output is correct
37 Correct 6 ms 468 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 6 ms 476 KB Output is correct
40 Correct 5 ms 468 KB Output is correct
41 Correct 6 ms 440 KB Output is correct
42 Correct 6 ms 496 KB Output is correct
43 Correct 5 ms 436 KB Output is correct
44 Correct 6 ms 468 KB Output is correct
45 Correct 6 ms 468 KB Output is correct
46 Correct 5 ms 468 KB Output is correct
47 Correct 6 ms 496 KB Output is correct
48 Correct 5 ms 440 KB Output is correct
49 Correct 7 ms 500 KB Output is correct
50 Correct 7 ms 484 KB Output is correct
51 Correct 5 ms 436 KB Output is correct
52 Correct 501 ms 13024 KB Output is correct
53 Correct 498 ms 12772 KB Output is correct
54 Correct 482 ms 12800 KB Output is correct
55 Correct 480 ms 12792 KB Output is correct
56 Correct 475 ms 12792 KB Output is correct
57 Correct 480 ms 12748 KB Output is correct
58 Correct 474 ms 12796 KB Output is correct
59 Correct 486 ms 12820 KB Output is correct
60 Correct 482 ms 12756 KB Output is correct
61 Correct 476 ms 12708 KB Output is correct
62 Correct 491 ms 12780 KB Output is correct
63 Correct 483 ms 12800 KB Output is correct
64 Correct 496 ms 12704 KB Output is correct
65 Correct 472 ms 12788 KB Output is correct
66 Correct 498 ms 12728 KB Output is correct
67 Correct 532 ms 12708 KB Output is correct
68 Correct 507 ms 12812 KB Output is correct