Submission #157233

#TimeUsernameProblemLanguageResultExecution timeMemory
157233manh9203스트랩 (JOI14_straps)C++17
45 / 100
27 ms23160 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second const int N = 2e3 + 5; long long n,dp[N][N]; pair<long long,int> rope[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i=1;i<=n;i++) cin >> rope[i].fi >> rope[i].se; sort(rope+1, rope+1+n); for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ dp[i][j] = max(dp[i-1][j], dp[i-1][min(n, j + rope[i].fi - 1)] + rope[i].se); } } cout << dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...