Submission #895338

# Submission time Handle Problem Language Result Execution time Memory
895338 2023-12-29T19:03:08 Z Isam Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 2396 KB
#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

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 time Memory Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -