Submission #895338

#TimeUsernameProblemLanguageResultExecution timeMemory
895338IsamArt Exhibition (JOI18_art)C++17
0 / 100
0 ms2396 KiB
#include<bits/stdc++.h> using ll = long long; using namespace std; constexpr int sz = 500005; pair<ll, ll> A[sz]; ll pref[sz], cost[sz]; signed main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int N; cin >> N; for(register int i(1); i <= N; ++i) cin >> A[i].first >> A[i].second; sort(A+1, A+N+1); for(register int i(1); i <= N; ++i) pref[i] = pref[i-1] + A[i].second; for(register int i(N); i >= 1; --i) cost[i] = max(cost[i+1], pref[i] - A[i].first); long long ans{-10000000000}; for(register int i(1); i <= N; ++i) ans = max(ans, cost[i] - (pref[i-1] - A[i].first)); cout << ans << '\n'; return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:12:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   12 |  for(register int i(1); i <= N; ++i) cin >> A[i].first >> A[i].second;
      |                   ^
art.cpp:14:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |  for(register int i(1); i <= N; ++i) pref[i] = pref[i-1] + A[i].second;
      |                   ^
art.cpp:15:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |  for(register int i(N); i >= 1; --i) cost[i] = max(cost[i+1], pref[i] - A[i].first);
      |                   ^
art.cpp:17:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |  for(register int i(1); i <= N; ++i) ans = max(ans, cost[i] - (pref[i-1] - A[i].first));
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...