# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108585 | vjudge1 | Art Exhibition (JOI18_art) | C++17 | 361 ms | 8276 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define priority_queue priority_queue<array<long long,2>, vector<array<long long,2>>, greater<array<long long,2>>>
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define pi 3.14159265358979323846
#define pb push_back
#define fi first
#define se second
#define ar array
#define int long long
void chay()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#define task "Hi"
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
const int N = 5e5, INF = 2e9+7;
const int block = 600;
const long long INFLL = 2e18+7;
long long M = 1e9+7;
int n;
ar<int,2> a[N+5];
void solve()
{
cin>>n;
for (int i = 1; i <= n; i++)
{
cin>>a[i][0]>>a[i][1];
}
sort(a+1, a+n+1);
int d = -a[1][0], kq = a[1][1], tong = 0;
for (int i = 1; i <= n; i++)
{
tong += a[i][1];
kq = max(kq, tong - a[i][0] - d);
d = min(d, tong - a[i+1][0]);
}
cout<<kq;
}
signed main ()
{
//chay();
int t = 1;
//cin>>t;
while (t--)
{
solve();
}
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... |