Submission #134196

# Submission time Handle Problem Language Result Execution time Memory
134196 2019-07-22T08:14:51 Z 송준혁(#3232) Popeala (CEOI16_popeala) C++14
17 / 100
2000 ms 10488 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=0;
		vector<int> V;
		for (int k=0; k<=M; k++) for (int l=0; l<=j; l++) V.push_back(P[i][k]+l);
		V.push_back(i);
		sort(V.begin(), V.end());
		V.erase(unique(V.begin(), V.end()), V.end());
		for (int k : V){
			if (k == 0) continue;
			if (k > i) break;
			while (t < M && P[i][t+1] < k) t++;
			D[i][j] = min(D[i][j], D[k-1][j-1] + (S[i]-S[k-1]) * 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 10 ms 9848 KB Output is correct
2 Correct 17 ms 9848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1226 ms 10076 KB Output is correct
2 Correct 1180 ms 10060 KB Output is correct
3 Correct 1219 ms 9976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 10488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9848 KB Output is correct
2 Correct 17 ms 9848 KB Output is correct
3 Correct 1226 ms 10076 KB Output is correct
4 Correct 1180 ms 10060 KB Output is correct
5 Correct 1219 ms 9976 KB Output is correct
6 Execution timed out 2041 ms 10488 KB Time limit exceeded
7 Halted 0 ms 0 KB -