Submission #937248

#TimeUsernameProblemLanguageResultExecution timeMemory
937248AndreyChorus (JOI23_chorus)C++14
40 / 100
532 ms2528 KiB
#include <bits/stdc++.h> using namespace std; int dp[501][501]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,x,br = 0; cin >> n >> x; string s; cin >> s; vector<int> bruh(0); for(int i = 0; i < 2*n; i++) { if(s[i] == 'A') { br++; } else { bruh.push_back(br); } } for(int i = 0; i <= n; i++) { dp[0][i] = 0; } for(int i = 1; i <= n; i++) { for(int k = 0; k <= n; k++) { dp[i][k] = 1e9; } int sb = 0; for(int j = i-1; j >= 0; j--) { sb+=max(0,i-bruh[j]); for(int k = 0; k < n; k++) { dp[i][k+1] = min(dp[i][k+1],dp[j][k]+sb); } } } cout << dp[n][x]; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...