# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289953 | Ruba_K | Art Exhibition (JOI18_art) | C++14 | 1092 ms | 20856 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;
const int N = 5e5 + 1 ;
#define ll long long
int main()
{
int n ;
cin >> n ;
vector<pair<ll , ll > > v (n);
for(auto &it : v)
cin >> it.first >> it.second ;
sort(v.begin() , v.end());
ll mx = 0 , past ;
for(int i = 0 ; i < n ; i ++){
if(v[i].first == past)continue ;
ll sum = 0 ;
for(int j = i; j < n ; j ++){
ll curr = v[j].first ;
ll d = v[j].first - v[i].first;
while(j < n && v[j].first == curr){
sum += v[j++].second ;
}
j -- ;
mx = max(mx , sum - d );
}
past = v[i].first ;
}
cout << mx ;
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... |