제출 #126157

#제출 시각아이디문제언어결과실행 시간메모리
126157AlexLuchianovArt Exhibition (JOI18_art)C++14
0 / 100
2 ms376 KiB
#include <iostream> #include <fstream> #include <algorithm> using namespace std; #define ll long long #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) < (b)) ? (b) : (a)) int const nmax = 500000; ll const inf = 1000000000000000; struct number{ ll cost; ll sz; bool operator < (number const &a) const{ return sz < a.sz; } }; number v[1 + nmax]; ll sum[1 + nmax]; int main() { int n; cin >> n; for(int i = 1;i <= n; i++){ cin >> v[i].sz >> v[i].cost; } sort(v + 1, v + n + 1); for(int i = 1;i <= n ; i++) sum[i] = sum[i - 1] + v[i].cost; ll smax = -inf; ll smin = inf; for(int i = 1;i <= n; i++){ smax = MAX(smax, sum[i] - v[i].sz - smin); smin = MIN(smin, sum[i - 1] - v[i].sz); } cout << smax; 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...