Submission #638914

# Submission time Handle Problem Language Result Execution time Memory
638914 2022-09-07T23:03:01 Z rc_catunta Stove (JOI18_stove) C++14
20 / 100
1000 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
    ios_base::sync_with_stdio(false);
    int N,K,x;
    vi guests;
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>x;
        guests.push_back(x);
    }
    // BITAMSK
    // (1<<N) = 2^N
    int tiempo_minimo = 1000000010;
    for(int i=1;i<(1<<N);i++){
        // Recorres los bits
        int tiempo = 0;
        bool valido = true;
        int cfosforos = 0;
        int pos_prendido_anterior = 0;
        for(int pos=0;pos<N;pos++){
            if((i&(1<<pos))>0){ // Prendido
                cfosforos++;
                if(pos!=0){
                    tiempo += guests[pos-1]+1-guests[pos_prendido_anterior];
                    
                }   
                pos_prendido_anterior = pos;          
            }
            else{ // Apagado
                if(pos==0){
                    valido = false;
                    break;
                }

            }
        }
        tiempo += guests[N-1]+1-guests[pos_prendido_anterior];
       
        if(cfosforos<=K and valido){
            tiempo_minimo = min(tiempo_minimo,tiempo);
        }
    }
    cout<<tiempo_minimo<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 34 ms 316 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 34 ms 316 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Execution timed out 1075 ms 340 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 34 ms 316 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Execution timed out 1075 ms 340 KB Time limit exceeded
11 Halted 0 ms 0 KB -