제출 #728347

#제출 시각아이디문제언어결과실행 시간메모리
728347viwlesxqArt Exhibition (JOI18_art)C++17
50 / 100
1063 ms28580 KiB
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; typedef string str; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector <pair <ll, ll>> v; ll a[n], b[n]; for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; v.push_back({a[i], b[i]}); } sort(v.begin(), v.end()); for (int i = 0; i < n; ++i) { a[i] = v[i].first; b[i] = v[i].second; } ll ans = -1; for (int i = 0; i < n; ++i) { ll S = 0; for (int j = i; j < n; ++j) { S += b[j]; ans = max(ans, S - (a[j] - a[i])); } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...