# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
1032652 |
2024-07-24T05:15:39 Z |
김은성(#10965) |
조교 (CEOI16_popeala) |
C++17 |
|
268 ms |
6884 KB |
#include <bits/stdc++.h>
using namespace std;
int p[20009], dp[52][20009];
int n, r[52][20009];
char res[20009];
int solved(int s, int e){
int ans = 0, i;
for(i=1; i<=n; i++){
if(r[i][e] - r[i][s-1] == e-s+1)
ans++;
}
return ans;
}
void go(int idx, int l, int r, int pl, int pr){
if(l>r)
return;
int mid = (l+r)/2, opt = -123423243, k, temp = 2147000000;
for(k=pl; k<=pr && k<mid; k++){
int x = dp[idx-1][k] + solved(k+1, mid) * (p[mid] - p[k]);
if(x < temp){
temp = x;
opt = k;
}
}
dp[idx][mid] = temp;
go(idx, l, mid-1, pl, min(opt+40, pr));
go(idx, mid+1, r, max(opt-40, pl), pr);
}
int main(){
int t, s, i, j;
scanf("%d %d %d", &n, &t, &s);
for(i=1; i<=t; i++){
scanf("%d", &p[i]);
p[i] += p[i-1];
}
for(i=1; i<=n; i++){
scanf(" %s", res+1);
for(j=1; j<=t; j++)
r[i][j] = r[i][j-1] + res[j] - '0';
}
for(i=1; i<=t; i++)
dp[1][i] = solved(1, i) * p[i];
for(i=2; i<=s; i++){
go(i, i, t, i-1, t-1);
}
for(i=1;i <=s; i++)
printf("%d\n", dp[i][t]);
return 0;
}
Compilation message
popeala.cpp: In function 'int main()':
popeala.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
31 | scanf("%d %d %d", &n, &t, &s);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
popeala.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | scanf("%d", &p[i]);
| ~~~~~^~~~~~~~~~~~~
popeala.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | scanf(" %s", res+1);
| ~~~~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
55 ms |
4700 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
268 ms |
6884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Incorrect |
55 ms |
4700 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |