제출 #306488

#제출 시각아이디문제언어결과실행 시간메모리
306488TemmieArt Exhibition (JOI18_art)C++17
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> typedef long long ll; int main() { std::ios::sync_with_stdio(0); std::cin.tie(0); int n; std::cin >> n; std::vector <std::pair <ll, ll>> a(n); for (auto& p : a) std::cin >> p.first >> p.second; std::sort(a.begin(), a.end()); ll ans = a[0].second; for (ll i = 0, sum = 0, max = a[0].first; (int)i < n; i++) { sum += a[i].second; max = std::max(max, a[i].first - sum - a[i].second); ans = std::max(ans, sum + max - a[i].first); } std::cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...