Submission #1229148

#TimeUsernameProblemLanguageResultExecution timeMemory
1229148who-read-is-dogArt Exhibition (JOI18_art)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
typedef int long long;
const int N = 1e5 + 5;
vector<pair<int, int>> a(N);
vector<int> ok(N);
int INF = 1e18;
signed main(){
    int n; cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());
    ok[1] = a[1].second;
    for(int i = 2; i <= n; i++){
        ok[i] = ok[i - 1] + a[i].second;
    }
    // ok[r] - ok[l - 1] - a[r].first + a[l].first
    int res = -INF; int maxping = -INF;
    for(int i = 1; i <= n; i++){
        res = max(res, a[i].first - ok[i - 1]);
        maxping = max(maxping, res - a[i].first + ok[i]);
    }
    cout << maxping;
}

Compilation message (stderr)

art.cpp:3:18: error: declaration does not declare anything [-fpermissive]
    3 | typedef int long long;
      |                  ^~~~
art.cpp:7:11: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    7 | int INF = 1e18;
      |           ^~~~