Submission #335933

#TimeUsernameProblemLanguageResultExecution timeMemory
335933Killer2501Art Exhibition (JOI18_art)C++14
50 / 100
231 ms48492 KiB
#include<bits/stdc++.h> #define ll long long #define fi first #define se second #define pll pair<ll, ll> #define pb push_back #define pii pair<ll ,pll> #define task "C" using namespace std; const int N = 3e5+5; const int M = 4e6+5; const int mod = 1e9+7; ll n, t, m, k, a[N], b[N], ans, tong, h[N], u, v; string s; bool ok; pll p[N]; struct dang { ll x, y, id; dang(){} dang(ll x, ll y, ll id): x(x), y(y), id(id){} }; vector<dang> adj[N]; bool cmp(const dang& u, const dang& v) { return ((u.x < v.x) || (u.x == v.x && u.y < v.y)); } void ss(ll x, ll y, dang z) { if(x == z.x && y == z.y) { ok = true; ans = z.id; } } void sol() { cin >> n; for(int i = 1; i <= n; i ++) { cin >> p[i].fi >> p[i].se; } sort(p+1, p+1+n); ans = p[1].se; a[1] = p[1].se; k = -p[1].fi; for(int i = 2; i <= n; i ++) { a[i] = a[i-1] + p[i].se; ans = max(p[i].se, max(ans, a[i] - p[i].fi - k)); //cout << a[i] - p[i].fi <<" "<<k<<'\n'; k = min(k, a[i-1] - p[i].fi); } cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int ntest = 1; //cin >> ntest; while(ntest -- > 0) sol(); }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   67 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   68 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...