# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72992 | garyye | Art Exhibition (JOI18_art) | C++14 | 357 ms | 8652 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// author: gary
// created: 2018/08/27 14:14:01
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <limits>
#include <utility>
#include <functional>
#include <string>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;
#define SZ(x) ( (int) (x).size() )
#define ALL(c) (c).begin(), (c).end()
#define CNT(c, x) ((c).find(x) != (c).end())
typedef long long ll;
typedef pair<ll, int> pii;
template<class T> bool cmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool cmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
const int N = 5e5 + 10;
int n;
pii p[N];
int main() {
scanf("%d", &n);
for(int i = 0; i < n; i++) {
scanf("%lld%d", &p[i].first, &p[i].second);
}
sort(p, p + n);
ll ans = -(1LL << 62);
ll best = -(1LL << 62);
ll sum = 0;
for(int i = 0; i < n; i++) {
ll nsum = sum + p[i].second;
cmax(best, -sum + p[i].first);
cmax(ans, nsum - p[i].first + best);
sum = nsum;
}
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |