# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
542888 | 2022-03-28T11:46:59 Z | Aldas25 | Art Exhibition (JOI18_art) | C++14 | 195 ms | 20928 KB |
/* //#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") */ #include <bits/stdc++.h> using namespace std; #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define pb push_back #define f first #define s second typedef long double ld; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vii; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 500100, MAXK = 20; const ll INF = 1e16; //const ll MOD = 1e9+7; //const ll MOD = 998244353; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } int n; vector<pair<ll, ll>> a; int main() { setIO(); cin >> n; REP(n) { ll x, y; cin >> x >> y; a.pb({x, y}); } sort(a.begin(), a.end()); ll mn = INF; ll pref = 0; ll ans = 0; FOR(i, 0, n-1) { mn = min (mn, pref - a[i].f); pref += a[i].s; ans = max(ans, pref-a[i].f-mn); } cout << ans << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 324 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 324 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 328 KB | Output is correct |
22 | Correct | 1 ms | 324 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 336 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 324 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 328 KB | Output is correct |
22 | Correct | 1 ms | 324 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 336 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 2 ms | 588 KB | Output is correct |
28 | Correct | 2 ms | 588 KB | Output is correct |
29 | Correct | 2 ms | 648 KB | Output is correct |
30 | Correct | 2 ms | 596 KB | Output is correct |
31 | Correct | 2 ms | 596 KB | Output is correct |
32 | Correct | 2 ms | 596 KB | Output is correct |
33 | Correct | 2 ms | 596 KB | Output is correct |
34 | Correct | 2 ms | 644 KB | Output is correct |
35 | Correct | 3 ms | 596 KB | Output is correct |
36 | Correct | 2 ms | 596 KB | Output is correct |
37 | Correct | 3 ms | 588 KB | Output is correct |
38 | Correct | 3 ms | 560 KB | Output is correct |
39 | Correct | 3 ms | 596 KB | Output is correct |
40 | Correct | 2 ms | 596 KB | Output is correct |
41 | Correct | 3 ms | 580 KB | Output is correct |
42 | Correct | 3 ms | 596 KB | Output is correct |
43 | Correct | 2 ms | 596 KB | Output is correct |
44 | Correct | 3 ms | 596 KB | Output is correct |
45 | Correct | 3 ms | 596 KB | Output is correct |
46 | Correct | 2 ms | 596 KB | Output is correct |
47 | Correct | 3 ms | 596 KB | Output is correct |
48 | Correct | 2 ms | 576 KB | Output is correct |
49 | Correct | 2 ms | 596 KB | Output is correct |
50 | Correct | 2 ms | 596 KB | Output is correct |
51 | Correct | 2 ms | 596 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 324 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 328 KB | Output is correct |
22 | Correct | 1 ms | 324 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 336 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 2 ms | 588 KB | Output is correct |
28 | Correct | 2 ms | 588 KB | Output is correct |
29 | Correct | 2 ms | 648 KB | Output is correct |
30 | Correct | 2 ms | 596 KB | Output is correct |
31 | Correct | 2 ms | 596 KB | Output is correct |
32 | Correct | 2 ms | 596 KB | Output is correct |
33 | Correct | 2 ms | 596 KB | Output is correct |
34 | Correct | 2 ms | 644 KB | Output is correct |
35 | Correct | 3 ms | 596 KB | Output is correct |
36 | Correct | 2 ms | 596 KB | Output is correct |
37 | Correct | 3 ms | 588 KB | Output is correct |
38 | Correct | 3 ms | 560 KB | Output is correct |
39 | Correct | 3 ms | 596 KB | Output is correct |
40 | Correct | 2 ms | 596 KB | Output is correct |
41 | Correct | 3 ms | 580 KB | Output is correct |
42 | Correct | 3 ms | 596 KB | Output is correct |
43 | Correct | 2 ms | 596 KB | Output is correct |
44 | Correct | 3 ms | 596 KB | Output is correct |
45 | Correct | 3 ms | 596 KB | Output is correct |
46 | Correct | 2 ms | 596 KB | Output is correct |
47 | Correct | 3 ms | 596 KB | Output is correct |
48 | Correct | 2 ms | 576 KB | Output is correct |
49 | Correct | 2 ms | 596 KB | Output is correct |
50 | Correct | 2 ms | 596 KB | Output is correct |
51 | Correct | 2 ms | 596 KB | Output is correct |
52 | Correct | 182 ms | 20768 KB | Output is correct |
53 | Correct | 183 ms | 20804 KB | Output is correct |
54 | Correct | 180 ms | 20908 KB | Output is correct |
55 | Correct | 176 ms | 20920 KB | Output is correct |
56 | Correct | 183 ms | 20836 KB | Output is correct |
57 | Correct | 176 ms | 20904 KB | Output is correct |
58 | Correct | 183 ms | 20836 KB | Output is correct |
59 | Correct | 178 ms | 20824 KB | Output is correct |
60 | Correct | 180 ms | 20820 KB | Output is correct |
61 | Correct | 177 ms | 20776 KB | Output is correct |
62 | Correct | 180 ms | 20904 KB | Output is correct |
63 | Correct | 183 ms | 20840 KB | Output is correct |
64 | Correct | 184 ms | 20908 KB | Output is correct |
65 | Correct | 184 ms | 20880 KB | Output is correct |
66 | Correct | 182 ms | 20908 KB | Output is correct |
67 | Correct | 178 ms | 20928 KB | Output is correct |
68 | Correct | 195 ms | 20828 KB | Output is correct |