# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710843 | Jovan26 | Art Exhibition (JOI18_art) | C++14 | 684 ms | 50044 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;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
#define int long long
int n;
cin>>n;
int a1[n];
int b[n];
map<int, int> mapa;
for(int i=0;i<n;i++){
cin>>a1[i]>>b[i];
mapa[a1[i]]+=b[i];
}
sort(a1,a1+n);
vector<int> a;
for(int i=0;i<n;i++){
if(i==0 || a1[i]!=a1[i-1]) a.push_back(a1[i]);
}
//int o = 0;
int dp[a.size()];
dp[0] = mapa[a[0]];
int o = dp[0];
for(int i=1;i<a.size();i++){
//if(i!=0 && a[i]==a[i-1]) continue;
dp[i] = max(dp[i-1]-a[i]+a[i-1]+mapa[a[i]], mapa[a[i]]);
o = max(o, dp[i]);
}
//cout<<dp[1].second<<endl;
cout<<o<<endl;
}
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... |