# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127292 | 2019-07-09T07:53:46 Z | DodgeBallMan | Popeala (CEOI16_popeala) | C++14 | 58 ms | 44064 KB |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int K = 55; int dp[N][K], last[N][K], t, n, s, qs[N]; int main() { memset( dp, 127, sizeof dp ); scanf("%d %d %d",&n,&t,&s); for( int i = 1, va ; i <= t ; i++ ) { scanf("%d",&va); qs[i] = qs[i-1] + va; } for( int i = 1 ; i <= n ; i++ ) { char score[N]; scanf("%s",score); for( int j = 1 ; j <= t ; j++ ) { if( score[j-1] == '1' ) last[j][i] = last[j-1][i]; else last[j][i] = j; } } for( int i = 1 ; i <= t ; i++ ) { last[i][n+1] = i; sort( last[i] + 1, last[i] + 2 + n ); } // for( int j = 1 ; j <= t ; j++ ) { // for( int i = 1 ; i <= n ; i++ ) { // printf("%d ",last[j][i]); // } // printf("\n"); // } dp[0][0] = 0; for( int i = 1 ; i <= t ; i++ ) dp[i][1] = 0; for( int i = 1 ; i <= t ; i++ ) { for( int j = 1 ; j <= n ; j++ ) { if( last[i][j] == 0 ) dp[i][1] += qs[i]; } } for( int i = 1 ; i <= t ; i++ ) { for( int j = 2 ; j <= min( s, i ) ; j++ ) { int cnt = 0; for( int k = n ; k >= 1 ; k-- ) if( last[i][k] == i ) cnt++; dp[i][j] = min( dp[i][j], dp[i-1][j-1] + ( qs[i] - qs[i-1] ) * ( n - cnt ) ); for( int k = n - cnt ; k >= 1 ; k-- ) { if( last[i][k] != last[i][k-1] ) dp[i][j] = min( dp[i][j], dp[last[i][k]-1][j-1] + ( qs[i] - qs[last[i][k]-1] ) * ( k - 1 ) ); } } } // printf("\n"); // for( int i = 1 ; i <= t ; i++ ) { // for( int j = 1 ; j <= s ; j++ ) { // printf("%d ",dp[i][j]); // } // printf("\n"); // } // printf("\n"); for( int i = 1 ; i <= s ; i++ ) printf("%d\n", dp[t][i] ); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 43384 KB | Output is correct |
2 | Incorrect | 38 ms | 43384 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 42 ms | 43516 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 58 ms | 44064 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 43384 KB | Output is correct |
2 | Incorrect | 38 ms | 43384 KB | Output isn't correct |