제출 #459652

#제출 시각아이디문제언어결과실행 시간메모리
459652Hamed5001Art Exhibition (JOI18_art)C++14
0 / 100
0 ms204 KiB
#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 << endl;
}

int main() {

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

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...