Submission #567086

# Submission time Handle Problem Language Result Execution time Memory
567086 2022-05-23T07:55:58 Z katwamiaw Kitchen (BOI19_kitchen) C++14
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>
#define ll long long
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define endl '\n'
#define pb push_back
using namespace std ;
//fflush(stdout) ;

const int Max_n=305 ;
int a[Max_n] , b[Max_n] ;

int main(){
    int n , m , k ; cin >> n >> m >> k ;

    for(int i=0 ; i<n ; i++) cin >> a[i] ;
    for(int i=0 ; i<m ; i++) cin >> b[i] ;

    if(m<=2){
        int sum_a=0 , sum_b=0 ;
        for(int i=0 ; i<n ; i++) sum_a+=a[i] ;
        for(int i=0 ; i<m ; i++) sum_b+=b[i] ;

        if(k>m){
            cout << "Impossible" ;
            return 0 ;
        }
        if(k==m){
            if(sum_a>sum_b){
                cout << "Impossible" ;
                return 0 ;
            }
            int r=0 ;
            for(int i=0 ; i<n ; i++){
                if(a[i]<k){
                    cout << "Impossible" ;
                    return 0 ;
                }
            }
            for(int i=0 ; i<m ; i++){
                if(b[i]<n){
                    cout << "Impossible" ;
                    return 0 ;
                }
            }
            cout << sum_b-sum_a ;
        }
        else{
            int ans=400 ;
            if(b[0]>=sum_a) ans=b[0]-sum_a ;
            if(b[1]>=sum_a) ans=min(b[0]-sum_a,ans) ;

            if(ans==400){
                if(sum_a>sum_b){
                    cout << "Impossible" ;
                    return 0 ;
                }
                cout << sum_b-sum_a ;
            }
        }
    }
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:33:17: warning: unused variable 'r' [-Wunused-variable]
   33 |             int r=0 ;
      |                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -