| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 901562 | Tuanlinh123 | Chorus (JOI23_chorus) | C++17 | 7092 ms | 4700 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;
const ll inf=2e9, maxn=1e3;
ll n, k, a[maxn], dp[maxn][maxn];
ll cost(ll j, ll i)
{
ll ans=0;
for (ll k=j+1; k<=i; k++)
if (a[k]>=j)
ans+=a[k]-j;
return ans;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
string s; cin >> s;
ll x=0, y=0, crr=1;
for (ll i=0; i<n*2; i++)
{
if (s[i]=='A')
x++, a[x]=y;
else y++;
}
for (ll i=0; i<=k; i++)
for (ll j=0; j<=n; j++)
dp[i][j]=inf*inf;
dp[0][0]=0;
for (ll i=1; i<=k; i++)
for (ll j=1; j<=n; j++)
for (ll z=0; z<j; z++)
dp[i][j]=min(dp[i][j], dp[i-1][z]+cost(z, j));
cout << dp[k][n];
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
