Submission #169079

# Submission time Handle Problem Language Result Execution time Memory
169079 2019-12-18T10:36:34 Z HuyQuang_re_Zero Stove (JOI18_stove) C++14
20 / 100
25 ms 376 KB
#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

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 time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 25 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 25 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Incorrect 3 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 25 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Incorrect 3 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -