# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
581998 | hibiki | Art Exhibition (JOI18_art) | C++11 | 1 ms | 212 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 pb push_back
int n;
long long a[500005],b[500005],ans = 0, sum = 0, mi = 0;
vector<int> v;
int main()
{
scanf("%d",&n);
for(int i = 0; i < n; i++)
{
scanf("%d %d",&a[i],&b[i]);
v.pb(i);
}
sort(v.begin(),v.end(), [&](const int x,const int y) {
return a[x] < a[y];
});
int l = 0;
for(int r = 0; r < n; r++)
{
sum += b[v[r]];
mi = a[v[r]] - a[v[l]];
while(sum - mi < 0)
{
sum -= b[v[l]];
l++;
mi = a[v[r]] - a[v[l]];
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... |