Submission #1229399

#TimeUsernameProblemLanguageResultExecution timeMemory
1229399duyhoanhoArt Exhibition (JOI18_art)C++17
0 / 100
0 ms320 KiB
//ngocuti #include<bits/stdc++.h> #define int long long #define pii pair<int,int> #define fi first #define se second using namespace std; const int N = 5e5 + 10, oo = 1e16; int n, s[N]; pii a[N]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); if(fopen("task.inp","r")){ freopen("task.inp","r",stdin); freopen("task.out","w",stdout); } #define task "" if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> n; for(int i = 1; i <= n; i++) cin >> a[i].fi >> a[i].se; sort(a + 1, a + n + 1); int mx = 0; int ans = -oo; for(int i = 1; i <= n; i++){ s[i] = s[i - 1] + a[i].se; ans = max(ans, s[i] - a[i].fi + mx); mx = max(mx, a[i].fi - s[i - 1]); } cout<<ans; }

Compilation message (stderr)

art.cpp: In function 'int32_t main()':
art.cpp:17:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |       freopen("task.inp","r",stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
art.cpp:18:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |       freopen("task.out","w",stdout);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
art.cpp:22:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |       freopen(task".inp","r",stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
art.cpp:23:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |       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...