# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165368 | 2019-11-26T15:22:03 Z | Ruxandra985 | Popeala (CEOI16_popeala) | C++14 | 7 ms | 1656 KB |
#include <cstdio> #include <iostream> #define INF 3000000000 using namespace std; long long dp[51][20001]; long long ok[20010]; long long val[20010]; char res[51][20010]; long long mask[20010]; int biti1 (long long x){ int sol = 0; while (x){ sol = sol + (x&1); x/=2; } return sol; } int main() { FILE *fin = stdin; FILE *fout = stdout; int n,t,s,i,j,k,nr,p; fscanf (fin,"%d%d%d",&n,&t,&s); for (i=1;i<=t;i++){ fscanf (fin,"%lld",&val[i]); val[i]+=val[i-1]; } for (i=1;i<=n;i++){ for (j=1;j<=t;j++){ res[i][j] = fgetc(fin); while (res[i][j]!='1' && res[i][j]!='0') res[i][j] = fgetc(fin); } } for (j=1;j<=t;j++){ for (i=1;i<=n;i++) mask[j] = mask[j] * 2 + (res[i][j] - '0'); } for (i=0;i<=t;i++) for (j=0;j<=s;j++) dp[i][j] = INF; dp[0][0] = 0; for (i=1;i<=t;i++){ for (j=1;j<=s;j++){ nr = mask[i]; for (k=i;k;k--){ /// in subtaskul j sunt testele i..k nr = (nr & mask[k]); dp[i][j] = min(dp[i][j] , dp[k-1][j-1] + (long long)biti1(nr) * (val[i] - val[k-1])); } } } for (j=1;j<=s;j++) fprintf (fout,"%lld\n",dp[t][j]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 3 ms | 632 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 1400 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 1656 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 3 ms | 632 KB | Output isn't correct |