답안 #1121019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1121019 2024-11-28T10:30:20 Z Ryu Art Exhibition (JOI18_art) C++17
100 / 100
178 ms 24732 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define LL long long
 
#define rep(i, x) for(auto &i : (x))
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
#define left(x) ((x)<<1)
#define right(x) ((x)>>1)
#define LSOne(x) (x & -(x))
 
using namespace std;
using T = pair<pair<int, int>, int>;
 
const int SZ = 2e5 + 1;
const LL MOD = 1e9 + 7; 
const LL INF = 1e18 + 1;
 
LL bp (LL b, LL e, LL m = MOD) {
 if ( e == 0 ) return 1;
 LL T = bp(b, e / 2);
 T *= T; T %= m;
 if ( e & 1 ) T *= b;
 return T %= m;
}
 
LL nv_i (LL a) { return bp(a, MOD - 2); };
LL gcd (LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return (a * (b / gcd(a, b))); }
LL ceil (LL a, LL b) { return ((a + b - 1) / b); }
 
void solve() {
  int n;
  cin >> n;

  vector<pair<LL, LL>> ARTW(n + 1);
  vector<LL> AUX(n + 1);
  for(int i = 1; i <= n; i ++) {
    cin >> ARTW[i].F >> ARTW[i].S;
  }
  
  sort(all(ARTW));

  for(int i = 1; i <= n; i ++) {
    AUX[i] = AUX[i - 1] + ARTW[i].S;
  } 
  
  LL ans = 0, mn = ARTW[1].F;

  for(int i = 1; i <= n; i ++) {
    mn = min(mn, (AUX[i - 1] - ARTW[i].F));
    ans = max(ans, (AUX[i] - ARTW[i].F - mn));
  }
  
  cout << ans;
}
 
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
 
  solve();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 508 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 508 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 2 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 2 ms 764 KB Output is correct
30 Correct 3 ms 500 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 2 ms 592 KB Output is correct
33 Correct 2 ms 760 KB Output is correct
34 Correct 2 ms 692 KB Output is correct
35 Correct 2 ms 592 KB Output is correct
36 Correct 2 ms 592 KB Output is correct
37 Correct 2 ms 592 KB Output is correct
38 Correct 2 ms 592 KB Output is correct
39 Correct 2 ms 592 KB Output is correct
40 Correct 3 ms 592 KB Output is correct
41 Correct 3 ms 488 KB Output is correct
42 Correct 3 ms 592 KB Output is correct
43 Correct 2 ms 472 KB Output is correct
44 Correct 2 ms 592 KB Output is correct
45 Correct 3 ms 592 KB Output is correct
46 Correct 3 ms 592 KB Output is correct
47 Correct 2 ms 592 KB Output is correct
48 Correct 2 ms 592 KB Output is correct
49 Correct 2 ms 592 KB Output is correct
50 Correct 2 ms 592 KB Output is correct
51 Correct 3 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 508 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 2 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 2 ms 764 KB Output is correct
30 Correct 3 ms 500 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 2 ms 592 KB Output is correct
33 Correct 2 ms 760 KB Output is correct
34 Correct 2 ms 692 KB Output is correct
35 Correct 2 ms 592 KB Output is correct
36 Correct 2 ms 592 KB Output is correct
37 Correct 2 ms 592 KB Output is correct
38 Correct 2 ms 592 KB Output is correct
39 Correct 2 ms 592 KB Output is correct
40 Correct 3 ms 592 KB Output is correct
41 Correct 3 ms 488 KB Output is correct
42 Correct 3 ms 592 KB Output is correct
43 Correct 2 ms 472 KB Output is correct
44 Correct 2 ms 592 KB Output is correct
45 Correct 3 ms 592 KB Output is correct
46 Correct 3 ms 592 KB Output is correct
47 Correct 2 ms 592 KB Output is correct
48 Correct 2 ms 592 KB Output is correct
49 Correct 2 ms 592 KB Output is correct
50 Correct 2 ms 592 KB Output is correct
51 Correct 3 ms 592 KB Output is correct
52 Correct 156 ms 24724 KB Output is correct
53 Correct 144 ms 24732 KB Output is correct
54 Correct 173 ms 24716 KB Output is correct
55 Correct 158 ms 24724 KB Output is correct
56 Correct 134 ms 24732 KB Output is correct
57 Correct 143 ms 24648 KB Output is correct
58 Correct 165 ms 24724 KB Output is correct
59 Correct 170 ms 24652 KB Output is correct
60 Correct 139 ms 24728 KB Output is correct
61 Correct 165 ms 24648 KB Output is correct
62 Correct 136 ms 24588 KB Output is correct
63 Correct 178 ms 24720 KB Output is correct
64 Correct 129 ms 24648 KB Output is correct
65 Correct 145 ms 24596 KB Output is correct
66 Correct 131 ms 24648 KB Output is correct
67 Correct 165 ms 24720 KB Output is correct
68 Correct 144 ms 24648 KB Output is correct