# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112304 | Mercenary | Art Exhibition (JOI18_art) | C++14 | 480 ms | 28792 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.
#include<bits/stdc++.h>
using namespace std;
#define taskname "A"
#define pb push_back
#define mp make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 1e6;
int n;
pair<ld,ld> a[maxn];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if(fopen(taskname".INP","r")){
freopen(taskname".INP", "r",stdin);
freopen(taskname".OUT", "w",stdout);
}
cin >> n;
for(int i = 1 ; i <= n ; ++i){
cin >> a[i].first >> a[i].second;
}
sort(a + 1 , a + n + 1);
ld res = 0;
ld now = -1e21;
for(int i = 1 ; i <= n ; ++i){
a[i].second += a[i - 1].second;
now = max(+a[i].first-a[i - 1].second,now);
res = max(res , -a[i].first + a[i].second + now);
// cout << now << endl;
}
cout << fixed << setprecision(0) << res;
}
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... |