답안 #1117452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117452 2024-11-23T16:25:09 Z vjudge1 Art Exhibition (JOI18_art) C++17
100 / 100
136 ms 24852 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 336 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 1 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 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 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 1 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 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 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 504 KB Output is correct
26 Correct 1 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 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 1 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 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 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 504 KB Output is correct
26 Correct 1 ms 504 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 592 KB Output is correct
30 Correct 2 ms 592 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 592 KB Output is correct
34 Correct 2 ms 592 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 3 ms 592 KB Output is correct
40 Correct 2 ms 592 KB Output is correct
41 Correct 3 ms 472 KB Output is correct
42 Correct 2 ms 704 KB Output is correct
43 Correct 2 ms 592 KB Output is correct
44 Correct 2 ms 592 KB Output is correct
45 Correct 2 ms 592 KB Output is correct
46 Correct 3 ms 708 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 2 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 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 1 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 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 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 504 KB Output is correct
26 Correct 1 ms 504 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 592 KB Output is correct
30 Correct 2 ms 592 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 592 KB Output is correct
34 Correct 2 ms 592 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 3 ms 592 KB Output is correct
40 Correct 2 ms 592 KB Output is correct
41 Correct 3 ms 472 KB Output is correct
42 Correct 2 ms 704 KB Output is correct
43 Correct 2 ms 592 KB Output is correct
44 Correct 2 ms 592 KB Output is correct
45 Correct 2 ms 592 KB Output is correct
46 Correct 3 ms 708 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 2 ms 592 KB Output is correct
52 Correct 127 ms 24652 KB Output is correct
53 Correct 127 ms 23584 KB Output is correct
54 Correct 136 ms 24604 KB Output is correct
55 Correct 124 ms 24648 KB Output is correct
56 Correct 118 ms 24656 KB Output is correct
57 Correct 120 ms 24648 KB Output is correct
58 Correct 126 ms 24852 KB Output is correct
59 Correct 119 ms 24648 KB Output is correct
60 Correct 118 ms 24592 KB Output is correct
61 Correct 124 ms 24476 KB Output is correct
62 Correct 120 ms 24652 KB Output is correct
63 Correct 120 ms 24652 KB Output is correct
64 Correct 123 ms 24648 KB Output is correct
65 Correct 127 ms 24600 KB Output is correct
66 Correct 123 ms 24648 KB Output is correct
67 Correct 132 ms 24600 KB Output is correct
68 Correct 125 ms 24648 KB Output is correct