Submission #157252

#TimeUsernameProblemLanguageResultExecution timeMemory
157252manh9203스트랩 (JOI14_straps)C++17
100 / 100
40 ms31864 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,long long> 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<=n;j++){ dp[i][j] = max(dp[i-1][j], dp[i-1][min(n, j + rope[i].fi - 1)] + rope[i].se); } } cout << max(dp[n][0], 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...