제출 #536954

#제출 시각아이디문제언어결과실행 시간메모리
536954dantoh000조교 (CEOI16_popeala)C++14
8 / 100
33 ms1424 KiB
#include <bits/stdc++.h> using namespace std; int n,t,s; int p[505]; int r[505][55]; int mem[505][55]; int ct[505][505]; const int INF = 2000000001; int dp(int id, int k){ if (id == 0) return 0; if (k == 0) return INF; if (mem[id][k] != -1) return mem[id][k]; int ret = INF; for (int j = id-1; j >= k-1; j--){ ret = min(ret, dp(j,k-1) + (p[id]-p[j])*ct[j+1][id]); } //printf("dp %d %d = %d\n",id,k,ret); return mem[id][k] = ret; } int main(){ scanf("%d%d%d",&n,&t,&s); if (t > 500) return 0; for (int i = 1; i <= t; i++){ scanf("%d",&p[i]); p[i] += p[i-1]; } for (int i = 0; i < n; i++){ for (int j = 1 ; j <= t; j++){ char ch; scanf(" %c",&ch); r[i][j] = ch-'0'; } } for (int k = 0; k < n; k++){ for (int i = 1; i <= t; i++){ int cur = r[k][i]; ct[i][i] += cur; for (int j = i+1; j <= t; j++){ if (r[k][j] == 0) cur = 0; ct[i][j] += cur; } } } memset(mem,-1,sizeof(mem)); for (int i = 1; i <= s; i++){ printf("%d\n", dp(t,i)); } }

컴파일 시 표준 에러 (stderr) 메시지

popeala.cpp: In function 'int main()':
popeala.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d%d%d",&n,&t,&s);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
popeala.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%d",&p[i]);
      |         ~~~~~^~~~~~~~~~~~
popeala.cpp:31:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |             scanf(" %c",&ch);
      |             ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...