Submission #459653

# Submission time Handle Problem Language Result Execution time Memory
459653 2021-08-08T22:05:48 Z Hamed5001 Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

void solve() {
	int N;
	cin >> N;

	vector<pair<ll, ll>> AB(N);
	for (auto& [a, b] : AB)
		cin >> a >> b;

	sort(AB.begin(), AB.end());

	for (int i = 1; i < N; i++)
		AB[i].second += AB[i-1].second;

	ll ans = AB[0].second;
	for (int l = 0, r = 1; r < N; ++r) {
		ll tmp1 = AB[r].second - (l ? AB[l-1].second : 0) - AB[r].first + AB[l].first;
		ll tmp2 = AB[r].second - AB[r-1].second - AB[r].first*2;
		if (tmp2 >= tmp1) l = r;
		ans = max({ans, tmp1, tmp2});
	}

	cout << ans;
}

int main() {	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
}

Compilation message

art.cpp: In function 'void solve()':
art.cpp:11:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   11 |  for (auto& [a, b] : AB)
      |             ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -