제출 #701298

#제출 시각아이디문제언어결과실행 시간메모리
701298NourWaelArt Exhibition (JOI18_art)C++14
30 / 100
25 ms16736 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 { if(dp[i][last]!=-1e17) return dp[i][last]; else m=joi(i+1,i)+v[i].second-(v[i].first-v[last].first); } m=max(m,joi(i+1,last)); if(last!=-1) 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]=-1e17; } } 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...