Submission #701297

#TimeUsernameProblemLanguageResultExecution timeMemory
701297NourWaelArt Exhibition (JOI18_art)C++14
10 / 100
1074 ms8148 KiB
#include <iostream> #include <bits/stdc++.h> typedef long long ll; using namespace std; ll dp[1001][1001]; int n; vector<pair<ll,ll>>v; ll joi(int i , int last) { if(i==n) return 0; ll m=0; int j=i; if(last==-1) { m=joi(i+1,j)+v[i].second; } else { m=joi(i+1,i)+v[i].second-(v[i].first-v[last].first); } m=max(m,joi(i+1,last)); dp[i][last]=m; return m; } int main() { cin>>n; v.resize(n); for(int i=0;i<1001;i++) { for(int j=0;j<1001;j++) { dp[i][j]=-100000000000000007; } } for(int i=0;i<n;i++) { cin>>v[i].first>>v[i].second; } sort(v.begin(),v.end()); cout<<joi(0,-1); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...