Submission #1004344

# Submission time Handle Problem Language Result Execution time Memory
1004344 2024-06-21T08:04:35 Z 0pt1mus23 Kitchen (BOI19_kitchen) C++14
0 / 100
5 ms 7256 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> nxt[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> sef;
    for(auto v:chefs){
        sef.ins(v);
    }
    
    if(k==1){
        /*
            i ci time da, bos olan yere bir dene adam ekle
        */
        nxt[0]=sef;
        
        for(int i=0;i<n;i++){
            if(arr[i] && nxt[i].empty()){
                drop("Impossible");
            }
            while(!sef.empty()){
                int node = *sef.begin();
                sef.erase(sef.begin());
                if(arr[i]>node){
                    arr[i]-=node;
                }
                else{
                    sef.insert(node - arr[i]);
                    break;
                }
            }
            for(auto v:sef){
                nxt[i+1].ins(v);
            }
        }

        int ans=0;
        for(auto v:nxt[n]){
            ans+=v;
        }
        drop(ans);

    }

}   

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int tt = 1;
    // cin>>tt;
    
    while(tt--){
        mal();        
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7256 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 3 ms 4952 KB Output isn't correct
2 Halted 0 ms 0 KB -