답안 #742531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742531 2023-05-16T12:08:34 Z Cookie Art Exhibition (JOI18_art) C++14
100 / 100
212 ms 24656 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
const int x[4] = {1, -1, 0, 0};
const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 7;
const int mxn = 5e5 + 5, mxm = 1e5, sq = 400;
const int base = (1 << 18);
const ll inf = 1e9;
int n;
ll p[mxn + 1];
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    vt<pll>v(n);
    forr(i, 0, n){
        cin >> v[i].fi >> v[i].se;
    }
    sort(v.begin(), v.end());
    p[0] = 0;
    for(int i = 0; i < v.size(); i++){
        p[i + 1] = p[i] + v[i].se;
    }
    ll ans = -1e18, mx = -1e18;
    for(int i = 0; i < v.size(); i++){
        mx = max(mx, v[i].fi + -p[i]);
        ans = max(ans, p[i + 1] + mx - v[i].fi);
    }
    cout << ans;
    return(0);
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i = 0; i < v.size(); i++){
      |                    ~~^~~~~~~~~~
art.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i = 0; i < v.size(); i++){
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 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 352 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 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 352 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 3 ms 536 KB Output is correct
28 Correct 3 ms 536 KB Output is correct
29 Correct 2 ms 480 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 3 ms 480 KB Output is correct
33 Correct 2 ms 472 KB Output is correct
34 Correct 2 ms 480 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 2 ms 536 KB Output is correct
37 Correct 3 ms 480 KB Output is correct
38 Correct 2 ms 536 KB Output is correct
39 Correct 2 ms 480 KB Output is correct
40 Correct 2 ms 476 KB Output is correct
41 Correct 2 ms 536 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 4 ms 532 KB Output is correct
44 Correct 2 ms 484 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 3 ms 484 KB Output is correct
47 Correct 3 ms 468 KB Output is correct
48 Correct 3 ms 488 KB Output is correct
49 Correct 3 ms 536 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 2 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 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 352 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 3 ms 536 KB Output is correct
28 Correct 3 ms 536 KB Output is correct
29 Correct 2 ms 480 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 3 ms 480 KB Output is correct
33 Correct 2 ms 472 KB Output is correct
34 Correct 2 ms 480 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 2 ms 536 KB Output is correct
37 Correct 3 ms 480 KB Output is correct
38 Correct 2 ms 536 KB Output is correct
39 Correct 2 ms 480 KB Output is correct
40 Correct 2 ms 476 KB Output is correct
41 Correct 2 ms 536 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 4 ms 532 KB Output is correct
44 Correct 2 ms 484 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 3 ms 484 KB Output is correct
47 Correct 3 ms 468 KB Output is correct
48 Correct 3 ms 488 KB Output is correct
49 Correct 3 ms 536 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 2 ms 480 KB Output is correct
52 Correct 182 ms 23112 KB Output is correct
53 Correct 183 ms 23116 KB Output is correct
54 Correct 181 ms 23104 KB Output is correct
55 Correct 186 ms 24656 KB Output is correct
56 Correct 183 ms 24232 KB Output is correct
57 Correct 212 ms 24256 KB Output is correct
58 Correct 203 ms 24276 KB Output is correct
59 Correct 190 ms 24220 KB Output is correct
60 Correct 175 ms 24160 KB Output is correct
61 Correct 178 ms 24144 KB Output is correct
62 Correct 193 ms 24208 KB Output is correct
63 Correct 199 ms 24220 KB Output is correct
64 Correct 193 ms 24220 KB Output is correct
65 Correct 204 ms 24160 KB Output is correct
66 Correct 171 ms 24236 KB Output is correct
67 Correct 177 ms 24248 KB Output is correct
68 Correct 175 ms 24264 KB Output is correct