Submission #127377

#TimeUsernameProblemLanguageResultExecution timeMemory
127377sealnot123Popeala (CEOI16_popeala)C++14
26 / 100
2032 ms5752 KiB
#include<bits/stdc++.h> #define x first #define y second #define all(x) (x).begin(),(x).end() #define SZ(x) (int)(x).size() #define push_back pb #define emplace_back eb using namespace std; typedef long long LL; typedef double DD; typedef long double LD; typedef pair<int,int> PII; typedef pair<LL,LL> PLL; const int T = 20007, N = 52; LL dp[T][N], last[T][N], qs[T]; char str[T]; int main(){ int n, t, s; int i,j,k,l,a,b,c,d; scanf("%d%d%d",&n,&t,&s); for(i=1;i<=t;i++) scanf("%lld",&qs[i]), qs[i]+=qs[i-1]; for(i=1;i<=n;i++){ scanf(" %s",str+1); for(j=1;j<=t;j++){ if(str[j]=='1') last[j][i] = last[j-1][i]; else last[j][i] = j; /*printf("%lld ",last[j][i]);*/ } /*printf("\n");*/ } for(i=1;i<=s;i++) dp[0][i] = 1e16; for(i=1;i<=t;i++) dp[i][0] = 1e16; for(i=1;i<=t;i++){ sort(last[i]+1, last[i]+1+n); for(j=1;j<=s;j++){ dp[i][j] = 1e16; LL p = n; for(k=i;k>0;k--){ while(last[i][p]>=k) p--; dp[i][j] = min(dp[i][j], dp[k-1][j-1] + (qs[i]-qs[k-1])*p); } /*printf("%lld ",dp[i][j]);*/ } /*printf("\n");*/ } for(i=1;i<=s;i++) printf("%lld\n",dp[t][i]); return 0; }

Compilation message (stderr)

popeala.cpp: In function 'int main()':
popeala.cpp:19:12: warning: unused variable 'l' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
            ^
popeala.cpp:19:14: warning: unused variable 'a' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
              ^
popeala.cpp:19:16: warning: unused variable 'b' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
                ^
popeala.cpp:19:18: warning: unused variable 'c' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
                  ^
popeala.cpp:19:20: warning: unused variable 'd' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
                    ^
popeala.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&t,&s);
  ~~~~~^~~~~~~~~~~~~~~~~~~
popeala.cpp:21:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=t;i++) scanf("%lld",&qs[i]), qs[i]+=qs[i-1];
                    ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
popeala.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %s",str+1);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...