제출 #553248

#제출 시각아이디문제언어결과실행 시간메모리
553248sandry24Art Exhibition (JOI18_art)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define pb push_back #define mp make_pair #define f first #define s second void solve(){ int n; cin >> n; vector<pair<ll, ll>> a(n); for(int i = 0; i < n; i++) cin >> a[i].f >> a[i].s; sort(a.begin(), a.end()); vector<ll> prefix(n); prefix[0] = a[0].s; for(int i = 1; i < n; i++) prefix[i] = a[i].s + prefix[i-1]; ll ans = 0; for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++){ ll temp = 0; if(i == 0) temp += prefix[j]; else temp += prefix[j] - prefix[i]; temp -= a[j].f - a[i].f; ans = max(ans, temp); } } cout << ans << '\n'; } int main() { ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...