Submission #1108386

#TimeUsernameProblemLanguageResultExecution timeMemory
1108386KhanhDangArt Exhibition (JOI18_art)C++17
100 / 100
127 ms12164 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define FOR(i, a, b) for(int i=(a), _b=(b); i<=_b; i++) #define FORD(i, a, b) for(int i=(a), _b=(b); i>=_b; i--) #define BIT(i, j) ((i>>j)&1) #define pb push_back #define ii pair<ll, ll> #define pii pair<ll, ii> #define fi first #define se second #define task "task" const ll inf = 1e18; const ll mod = 1e9+7; const ll N = 500005; const ll M = 50005; ll n, s[N], ans, prefix[N], t; ii a[N]; void solve() { cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i].fi >> a[i].se; } sort(a+1, a+n+1); for(int i = 1; i <= n; i++) { prefix[i] = max(prefix[i-1], a[i].fi - t); t += a[i].se; ans = max(ans, t + prefix[i] - a[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); } solve(); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         freopen(task".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         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...