Submission #228037

# Submission time Handle Problem Language Result Execution time Memory
228037 2020-04-29T16:00:15 Z mohamedsobhi777 Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
682 ms 20516 KB
#include<bits/stdc++.h>

using namespace std ;

const int N = 1e5 + 7 ; 

int n , k ;
priority_queue<pair<int, int > > mu ; 

vector<pair<int , int> > arr ; 

int main(){
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
    //freopen("in.in" , "r" , stdin) ; 
    cin>>n>>k ; 

    for(int i = 0 ; i < n ; i++){
        int t ; 
        cin>>t ; 
        mu.push({ -t , i }) ; 
        arr.push_back({t , i }) ; 
    }
    while(k){
        if(mu.size() ==1 ){
            mu.push(mu.top()) ;
            arr.push_back(mu.top()) ; 
            k--;
            continue ; 
        }
        pair<int , int > t1 = mu.top() ; mu.pop() ; 
        pair<int , int > t2 = mu.top() ; mu.pop() ; 
        if(t1.first == t2.first ){
            mu.push({ t1.first -1 , t1.second -2 });
            continue ; 
        }
        else{
            mu.push(t2) ;
            mu.push(t1) ;
            mu.push(t1) ;  
            arr.push_back( t1 ); 
            k-- ; 
        }
    }
    sort(arr.begin() , arr.end() , [&] (pair<int , int > p1 , pair<int , int > p2) {
        return p1.second < p2.second ; 
    }) ; 
    for(auto u : arr){
        cout<<abs(u.first) <<" " ; 
    }

    return 0 ; 
} 
# Verdict Execution time Memory Grader output
1 Incorrect 664 ms 20384 KB not a zalsequence
2 Incorrect 651 ms 20516 KB not a zalsequence
3 Incorrect 646 ms 20432 KB not a zalsequence
4 Incorrect 664 ms 20396 KB not a zalsequence
5 Incorrect 682 ms 20388 KB not a zalsequence
6 Incorrect 652 ms 20344 KB not a zalsequence
# Verdict Execution time Memory Grader output
1 Incorrect 609 ms 20396 KB not a zalsequence
2 Incorrect 581 ms 20388 KB not a zalsequence
3 Incorrect 583 ms 20484 KB not a zalsequence
4 Incorrect 580 ms 20396 KB not a zalsequence
5 Incorrect 577 ms 20400 KB not a zalsequence
6 Incorrect 572 ms 20400 KB not a zalsequence
7 Incorrect 588 ms 20380 KB not a zalsequence
8 Incorrect 591 ms 20388 KB not a zalsequence
9 Incorrect 532 ms 19248 KB not a zalsequence
10 Incorrect 296 ms 16828 KB not a zalsequence
11 Incorrect 424 ms 17820 KB not a zalsequence
12 Incorrect 163 ms 15192 KB not a zalsequence
13 Incorrect 170 ms 15316 KB not a zalsequence
14 Incorrect 163 ms 15188 KB not a zalsequence