| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 835039 | kwongweng | Chorus (JOI23_chorus) | C++17 | 7021 ms | 79284 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define fi first
#define se second
void solve(){
int n,k; cin>>n>>k;
string s; cin>>s;
vi A(n+1); int a=1, b=0;
FOR(i,0,2*n){
if (s[i]=='B') b++;
else A[a++]=b;
}
vector<ll> S(n+1); FOR(i,1,n+1) S[i]=S[i-1]+A[i];
ll dp[n+1][k+1]; ms(dp,0,sizeof(dp));
FOR(i,1,n+1) dp[i][1]=S[i];
FOR(j,2,k+1){
FOR(i,1,n+1){
dp[i][j]=dp[i][j-1];
int cur=i;
FOR(l,1,i+1){
while (cur>i-l && A[cur]>i-l) cur--;
if (cur==i) dp[i][j]=min(dp[i][j],dp[i-l][j-1]);
else dp[i][j]=min(dp[i][j], dp[i-l][j-1] + S[i]-S[cur]-(ll)(i-cur)*(ll)(i-l));
}
}
}
cout<<dp[n][k]<<"\n";
}
int main(){
//MOD=MOD1;
ios::sync_with_stdio(false);
if (fopen("input.txt", "r")) {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
int TC = 1;
//cin >> TC;
FOR(i, 1, TC+1){
//cout << "Case #" << i << ": ";
solve();
}
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
