제출 #601180

#제출 시각아이디문제언어결과실행 시간메모리
601180jjianglyArt Exhibition (JOI18_art)C++14
50 / 100
20 ms824 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define siz(x) int(x.size()) #define ll long long #define ar array #define vt vector #define inf INT_MAX #define lnf LLONG_MAX const int nxm = int(5e3) + 7; int n; pair<ll, ll> a[nxm]; namespace sub3 { void solve() { sort(a, a + n); for (int i = 1; i < n; ++i) { a[i].second += a[i - 1].second; } ll ans = -lnf; for (int i = 0; i < n; ++i) { for (int j = i; j < n; ++j) { ans = max(ans, a[j].second - (i - 1 >= 0 ? a[i - 1].second : 0) - a[j].first + a[i].first); } } cout << ans << "\n"; } }; int subtask() { if (n <= 5000) { return 3; } return 4; }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i].first >> a[i].second; } if (subtask() == 3) { sub3::solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...