Submission #895331

# Submission time Handle Problem Language Result Execution time Memory
895331 2023-12-29T18:57:25 Z Isam Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 348 KB
#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<long long, long long>> 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] : -(int)(1e17)), pref[i] - A[i].first);
	}
	long long ans{-10000000000};
	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

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