답안 #924821

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924821 2024-02-09T19:41:33 Z SalihSahin Art Exhibition (JOI18_art) C++17
100 / 100
173 ms 36748 KB
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
using namespace std;
 
const int mod = 998244353;
const int inf = 1e16;
const int N = 55;

int32_t main(){
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<pair<int, int> > a(n);
    vector<int> vp(n+1);
    for(int i = 0; i < n; i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        vp[i+1] = vp[i] + a[i].second;
    }
    vector<pair<int, int> > pre(n);
    vector<int> v(n);
    v[0] = a[0].second;
    for(int i = 1; i < n; i++){
        v[i] = a[i].second - (a[i].first - a[i-1].first);
    }
    pre[0].first = v[0];
    pre[0].second = 0;
    for(int i = 1; i < n; i++){
        pre[i].first = pre[i-1].first + v[i];
        pre[i].second = i;
    }

    sort(pre.rbegin(), pre.rend());
    int pind = 0;
    int ans = 0;

    for(int i = 0; i < n; i++){
        while(pind < pre.size()-1 && pre[pind].second < i){
            pind++;
        }

        int x = pre[pind].second;
        int c = (vp[x+1] - vp[i]) - (a[x].first - a[i].first);
        ans = max(ans, c);
    }

    cout<<ans<<endl;
    return 0;
}

Compilation message

art.cpp: In function 'int32_t main()':
art.cpp:43:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         while(pind < pre.size()-1 && pre[pind].second < i){
      |               ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 816 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 660 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 724 KB Output is correct
35 Correct 2 ms 696 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 2 ms 604 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 600 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 2 ms 700 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 600 KB Output is correct
47 Correct 2 ms 704 KB Output is correct
48 Correct 2 ms 600 KB Output is correct
49 Correct 2 ms 856 KB Output is correct
50 Correct 2 ms 680 KB Output is correct
51 Correct 2 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 816 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 660 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 724 KB Output is correct
35 Correct 2 ms 696 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 2 ms 604 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 600 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 2 ms 700 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 600 KB Output is correct
47 Correct 2 ms 704 KB Output is correct
48 Correct 2 ms 600 KB Output is correct
49 Correct 2 ms 856 KB Output is correct
50 Correct 2 ms 680 KB Output is correct
51 Correct 2 ms 612 KB Output is correct
52 Correct 149 ms 36384 KB Output is correct
53 Correct 155 ms 36576 KB Output is correct
54 Correct 154 ms 36388 KB Output is correct
55 Correct 158 ms 36432 KB Output is correct
56 Correct 161 ms 36492 KB Output is correct
57 Correct 165 ms 36436 KB Output is correct
58 Correct 160 ms 36360 KB Output is correct
59 Correct 161 ms 36356 KB Output is correct
60 Correct 157 ms 36456 KB Output is correct
61 Correct 159 ms 36256 KB Output is correct
62 Correct 161 ms 36624 KB Output is correct
63 Correct 163 ms 36384 KB Output is correct
64 Correct 152 ms 36492 KB Output is correct
65 Correct 147 ms 36384 KB Output is correct
66 Correct 154 ms 36748 KB Output is correct
67 Correct 173 ms 36360 KB Output is correct
68 Correct 143 ms 36488 KB Output is correct