Submission #567112

# Submission time Handle Problem Language Result Execution time Memory
567112 2022-05-23T08:09:26 Z katwamiaw Kitchen (BOI19_kitchen) C++14
9 / 100
1 ms 300 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 ;
            }
            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[1]-sum_a,ans) ;

            if(ans==400){
                if(sum_a>sum_b){
                    cout << "Impossible" ;
                    return 0 ;
                }
                cout << sum_b-sum_a ;
            }
            else cout << ans ;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 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 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -