Submission #134165

# Submission time Handle Problem Language Result Execution time Memory
134165 2019-07-22T07:39:45 Z 송준혁(#3232) Popeala (CEOI16_popeala) C++14
0 / 100
49 ms 10428 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N, M, K;
LL S[20202];
LL D[20202][60];
int P[20202][60], tmp[60];

int main(){
	scanf("%d %d %d", &M, &N, &K);
	for (int i=1; i<=N; i++){
		scanf("%d", &S[i]);
		S[i] += S[i-1];
	}
	for (int i=1; i<=M; i++) for (int j=1; j<=N; j++){
		scanf("%1d", &P[j][i]);
		if (P[j][i] == 0) P[j][i] = j;
		else P[j][i] = P[j-1][i];
	}
	for (int i=1; i<=N; i++) sort(P[i]+1, P[i]+M+1);
	memset(D, 1, sizeof D);
	D[0][0] = 0;
	for (int i=1; i<=N; i++) for (int j=1; j<=K; j++){
		int t=M, k=i;
		while (t > 0 && P[i][t] >= k) t--;
		D[i][j] = min(D[i][j], D[k-1][j-1] + (S[i]-S[k-1]) * t);
		while (t > 0){
			k = P[i][t];
			D[i][j] = min(D[i][j], D[k][j-1] + (S[i]-S[k]) * t);
			while (t > 0 && P[i][t] >= k) t--;
			if (k != 0) D[i][j] = min(D[i][j], D[k-1][j-1] + (S[i]-S[k-1]) * t);
		}
		while (t<M && P[i][t+1] == 0) t++;
		D[i][j] = min(D[i][j], D[0][j-1] + S[i] * t);
	}
	for (int i=1; i<=K; i++) printf("%lld\n", D[N][i]);
	return 0;
} 

Compilation message

popeala.cpp: In function 'int main()':
popeala.cpp:14:20: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'LL* {aka long long int*}' [-Wformat=]
   scanf("%d", &S[i]);
               ~~~~~^
popeala.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &M, &N, &K);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
popeala.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &S[i]);
   ~~~~~^~~~~~~~~~~~~
popeala.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%1d", &P[j][i]);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 9848 KB Output is correct
2 Incorrect 10 ms 9848 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 9976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 10428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 9848 KB Output is correct
2 Incorrect 10 ms 9848 KB Output isn't correct