Submission #464476

# Submission time Handle Problem Language Result Execution time Memory
464476 2021-08-13T09:29:35 Z BT21tata Kitchen (BOI19_kitchen) C++17
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
#define SPEED ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define rall(v) (v).rbegin(),(v).rend()
#define all(v) (v).begin(),(v).end()
#define OK cerr<<"OK"<<endl<<flush
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define F first
#define S second
#define y0 jahdakdh
#define y1 jahsadakdakdh
#define endl '\n'
const ll MOD=1e9+7;
using namespace std;
//mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
 
int n, m, k, a[305], b[305];
int suma, sumb;
int main()
{
    SPEED;
    cin>>n>>m>>k;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        suma+=a[i];
    }
    for(int i=0; i<m; i++)
    {
        cin>>b[i];
        sumb+=b[i];
        if(b[i]<k) return cout<<"Impossible\n", 0;
    }
    sort(b, b+m);
    if(sumb<suma or m<k) return cout<<"Impossible\n", 0;
    if(k==1)
    {
        if(b[0]>=suma) cout<<b[0]-suma<<endl;
        else if(b[1]>=suma) cout<<b[1]-suma<<endl;
        else  cout<<sumb-suma<<endl;
    }
    else
    {
        if(b[0]<n) cout<<"Impossible\n";
        else cout<<sumb-suma<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -