Submission #895327

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

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:10:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   10 |  for(register int i(0); i < N; ++i){
      |                   ^
art.cpp:14:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |  for(register int i(0); i < N; ++i){
      |                   ^
art.cpp:17:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |  for(register int i(N - 1); i >= 0; --i){
      |                   ^
art.cpp:21:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   21 |  for(register int i(0); i < N; ++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...