Submission #169079

#TimeUsernameProblemLanguageResultExecution timeMemory
169079HuyQuang_re_ZeroStove (JOI18_stove)C++14
20 / 100
25 ms376 KiB
#include <bits/stdc++.h> using namespace std; int n,m,i,t[1001],kq,d[1001]; void vet(int i,int sl) { if(sl>m) return ; if(i>n) { int sum=0,vt; for(int j=1;j<=n;j++) { if(d[j]==1) vt=t[j]; if(j==n || d[j+1]==1) sum+=t[j]+1-vt; } kq=min(kq,sum); return ; } if(i==1) { d[i]=1; vet(i+1,sl+1); } else { for(int j=0;j<=1;j++) { d[i]=j; vet(i+1,sl+j); } } } void sub1() { kq=round(1e9); vet(1,0); cout<<kq; } int main() { //freopen("stove.inp","r",stdin); //freopen("stove.out","w",stdout); cin>>n>>m; for(i=1;i<=n;i++) cin>>t[i]; sub1(); }

Compilation message (stderr)

stove.cpp: In function 'void vet(int, int)':
stove.cpp:13:46: warning: 'vt' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if(j==n || d[j+1]==1) sum+=t[j]+1-vt;
                                        ~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...