답안 #1004356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004356 2024-06-21T08:16:04 Z 0pt1mus23 Kitchen (BOI19_kitchen) C++14
0 / 100
18 ms 5208 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> sef;
    for(auto v:chefs){
        sef.ins(v);
    }
    
    if(k==1){
        /*
            i ci time da, bos olan yere bir dene adam ekle
        */
        multiset<int> bosda;
        
        for(int i =1;i<=10000;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;
                }
            }
        }

        for(int i=0;i<n;i++){
            if(arr[i]){
                drop("Impossible");
            }
        }
        int ans=0;
        for(auto v:bosda){
            ans+=v;
        }
        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()){
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 5152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5208 KB Output isn't correct
2 Halted 0 ms 0 KB -