Submission #1004381

# Submission time Handle Problem Language Result Execution time Memory
1004381 2024-06-21T08:24:45 Z 0pt1mus23 Kitchen (BOI19_kitchen) C++14
0 / 100
229 ms 4956 KB
/*
    k=1
*/
#pragma GCC optimize("O3", "inline")
#include <bits/stdc++.h>
using namespace std;
#define ins insert
#define pb push_back
#define int long long int
#define pii pair<int, int>
#define endl '\n'
#define drop(x) cout<<(x)<<endl; return;
#define all(x) x.begin(),x.end()
const int mod = 1e9 +7, sze = 1e5, inf = 2e18, prime = 23;

int mn = inf;
multiset<int> var[sze+1];
        
void mal(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    vector<int> chefs(m);
    for(int i=0;i<m;i++){
        cin>>chefs[i];
    } 

    multiset<int> bosda;
    for(auto v:chefs){
        bosda.ins(v);
    }
    
    if(k==1){
        /*
            i ci time da, bos olan yere bir dene adam ekle
        */

        int ans=0;
        for(int i =1;i<=1000000;i++){
            for(int j=0;j<n;j++){
                if(arr[j]){
                    while(!bosda.empty() && var[j].size()<arr[j]){
                        var[j].ins((*bosda.begin()));
                        bosda.erase(bosda.begin());
                    }
                    arr[j]-=var[j].size();
                    multiset<int> lst;
                    for(auto v:var[j]){
                        if(v!=1){
                            lst.ins(v-1);
                        }
                    }
                    while(!lst.empty() && arr[j]<lst.size()){
                        bosda.insert(*lst.begin());
                        lst.erase(lst.begin());
                    }

                    var[j]=lst;
                }
            }
            ans+=bosda.size();
        }

        for(int i=0;i<n;i++){
            if(arr[i]){
                // cout<<arr[i]<<endl;
                drop("Impossible");
            }
        }
        // while(true){

        // }
        drop(ans);

    }

}   

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int tt = 1;
    // cin>>tt;
    
    while(tt--){
        mal();        
    }
}

Compilation message

kitchen.cpp: In function 'void mal()':
kitchen.cpp:45:58: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} [-Wsign-compare]
   45 |                     while(!bosda.empty() && var[j].size()<arr[j]){
kitchen.cpp:56:49: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |                     while(!lst.empty() && arr[j]<lst.size()){
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 229 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -