Submission #742531

#TimeUsernameProblemLanguageResultExecution timeMemory
742531CookieArt Exhibition (JOI18_art)C++14
100 / 100
212 ms24656 KiB
#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 (stderr)

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++){
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...