# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1137317 | danglayloi1 | 조교 (CEOI16_popeala) | C++20 | 5 ms | 9028 KiB |
#include <bits/stdc++.h>
#define ii pair<int, int>
#define fi first
#define se second
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = long long;
const ll mod=1e9+7;
const int nx=2e4+5;
int n, t, s, last[nx][55];
ll a[nx], dp[55][nx];
char c[55][nx];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
freopen("popeala.in", "r", stdin);
freopen("popeala.out", "w", stdout);
cin>>n>>t>>s;
for(int i = 1; i <= t; i++)
cin>>a[i], a[i]+=a[i-1];
for(int i = 0; i < n; i++)
{
for(int j = 1; j <= t; j++)
{
cin>>c[i][j];
last[j][i]=(c[i][j]=='1')?last[j-1][i]:j;
}
}
for(int i = 1; i <= t; i++)
{
last[i][n]=i;
sort(last[i], last[i]+n+1);
}
memset(dp, 0x3f, sizeof(dp));
dp[0][0]=0;
for(int i = 1; i <= s; i++)
{
for(int j = 1; j <= t; j++)
{
for(int k = 0; k <= n; k++)
{
ll tmp=inf;
for(int p = last[j-1][k]; p < last[j][k]; p++)
tmp=min(tmp, dp[i-1][p]-1ll*a[p]*k);
dp[i][j]=min(dp[i][j], tmp+1ll*a[j]*k);
}
}
cout<<dp[i][t]<<'\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... |