# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
1037706 |
2024-07-29T07:05:05 Z |
ㅇㅇ(223.39)(#11011) |
Chorus (JOI23_chorus) |
C++17 |
|
19 ms |
2444 KB |
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
using ll=long long;
const ll inf=1e18;
const int N=505;
int n,k,a[N],m;
string s;
ll S[N];
ll base,dp[N][N];
ll f(int l,int r){
ll ret=0;
for(int i=l;i<=r;i++) ret+=max(0,r+i-a[i]);
return ret;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>k>>s;
for(int i=1;i<=2*n;i++) if(s[i-1]=='B') a[++m]=i;
for(int i=1;i<=n;i++) if(a[i]<2*i){
base+=2*i-a[i];
a[i]=2*i;
}
for(int i=1;i<=n;i++) S[i]=S[i-1]+a[i];
for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) dp[i][j]=inf;
dp[0][0]=0;
for(int i=1;i<=n;i++) for(int j=0;j<i;j++){
ll cost=f(j+1,i);
debug(j+1,i,cost);
for(int c=1;c<=j+1;c++) dp[i][c]=min(dp[i][c],dp[j][c-1]+cost);
}
cout<<base+dp[n][k];
return 0;
}
Compilation message
chorus.cpp: In function 'int main()':
chorus.cpp:9:20: warning: statement has no effect [-Wunused-value]
9 | #define debug(...) 42
| ^~
chorus.cpp:36:3: note: in expansion of macro 'debug'
36 | debug(j+1,i,cost);
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
15 ms |
2440 KB |
Output is correct |
19 |
Correct |
15 ms |
2396 KB |
Output is correct |
20 |
Correct |
16 ms |
2396 KB |
Output is correct |
21 |
Correct |
16 ms |
2396 KB |
Output is correct |
22 |
Correct |
15 ms |
2440 KB |
Output is correct |
23 |
Correct |
19 ms |
2396 KB |
Output is correct |
24 |
Correct |
15 ms |
2444 KB |
Output is correct |
25 |
Correct |
16 ms |
2392 KB |
Output is correct |
26 |
Correct |
18 ms |
2436 KB |
Output is correct |
27 |
Correct |
15 ms |
2396 KB |
Output is correct |
28 |
Correct |
15 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
15 ms |
2440 KB |
Output is correct |
19 |
Correct |
15 ms |
2396 KB |
Output is correct |
20 |
Correct |
16 ms |
2396 KB |
Output is correct |
21 |
Correct |
16 ms |
2396 KB |
Output is correct |
22 |
Correct |
15 ms |
2440 KB |
Output is correct |
23 |
Correct |
19 ms |
2396 KB |
Output is correct |
24 |
Correct |
15 ms |
2444 KB |
Output is correct |
25 |
Correct |
16 ms |
2392 KB |
Output is correct |
26 |
Correct |
18 ms |
2436 KB |
Output is correct |
27 |
Correct |
15 ms |
2396 KB |
Output is correct |
28 |
Correct |
15 ms |
2396 KB |
Output is correct |
29 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
15 ms |
2440 KB |
Output is correct |
19 |
Correct |
15 ms |
2396 KB |
Output is correct |
20 |
Correct |
16 ms |
2396 KB |
Output is correct |
21 |
Correct |
16 ms |
2396 KB |
Output is correct |
22 |
Correct |
15 ms |
2440 KB |
Output is correct |
23 |
Correct |
19 ms |
2396 KB |
Output is correct |
24 |
Correct |
15 ms |
2444 KB |
Output is correct |
25 |
Correct |
16 ms |
2392 KB |
Output is correct |
26 |
Correct |
18 ms |
2436 KB |
Output is correct |
27 |
Correct |
15 ms |
2396 KB |
Output is correct |
28 |
Correct |
15 ms |
2396 KB |
Output is correct |
29 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
15 ms |
2440 KB |
Output is correct |
19 |
Correct |
15 ms |
2396 KB |
Output is correct |
20 |
Correct |
16 ms |
2396 KB |
Output is correct |
21 |
Correct |
16 ms |
2396 KB |
Output is correct |
22 |
Correct |
15 ms |
2440 KB |
Output is correct |
23 |
Correct |
19 ms |
2396 KB |
Output is correct |
24 |
Correct |
15 ms |
2444 KB |
Output is correct |
25 |
Correct |
16 ms |
2392 KB |
Output is correct |
26 |
Correct |
18 ms |
2436 KB |
Output is correct |
27 |
Correct |
15 ms |
2396 KB |
Output is correct |
28 |
Correct |
15 ms |
2396 KB |
Output is correct |
29 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
30 |
Halted |
0 ms |
0 KB |
- |