제출 #715888

#제출 시각아이디문제언어결과실행 시간메모리
715888JuanArt Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> #define ff first #define ss second const int maxn = 5e5 + 5, INF = 0x3f3f3f3f3f3f3f3f; pii v[maxn]; int32_t main(){ int n; cin >> n; for(int i = 0; i < n; i++) cin >> v[i].ff >> v[i].ss; sort(v, v+n); int sum = 0, mx = -INF, ans = v[0].ff + v[0].ss; for(int i = 0; i < n; i++){ sum += v[i].ss; if(i) ans = max(ans, -v[i].ff +sum +mx); mx = max(mx, -sum+v[i].ss+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...