Submission #955264

#TimeUsernameProblemLanguageResultExecution timeMemory
955264yellowtoad스트랩 (JOI14_straps)C++17
0 / 100
23 ms31836 KiB
#include <iostream> #include <algorithm> #define f first #define s second using namespace std; long long n, x, y, dp[2010][2010], maxx; int main() { cin >> n; dp[0][0] = -1e18; for (int i = 2; i <= n; i++) dp[0][i] = -1e18; for (int i = 1; i <= n; i++) { cin >> x >> y; for (int j = 0; j < n; j++) { dp[i][j] = dp[i-1][j]; if (j-x+1 >= 0) dp[i][j] = max(dp[i][j],dp[i-1][j-x+1]+y); } dp[i][n] = dp[i-1][n]; for (int j = n-x+1; j <= n; j++) dp[i][n] = max(dp[i][n],dp[i-1][j]+y); } for (int i = 0; i <= n; i++) maxx = max(maxx,dp[n][i]); cout << maxx << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...