Submission #46274

#TimeUsernameProblemLanguageResultExecution timeMemory
46274fredbrArt Exhibition (JOI18_art)C++17
50 / 100
32 ms4800 KiB
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; typedef long long ll; typedef pair<ll, ll> ii; const int maxn = 5010; const ll inf = 0x3f3f3f3f3f3f3f; ll p[maxn]; ii v[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> v[i].ff >> v[i].ss; sort(v+1, v+1+n); for (int i = 1; i <= n; i++) p[i] = p[i-1] + v[i].ss; ll ans = -inf; for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) { ans = max(ans, p[j]-p[i-1]-v[j].ff+v[i].ff); } } 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...