답안 #377316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
377316 2021-03-13T21:44:06 Z hhh07 Kitchen (BOI19_kitchen) C++14
0 / 100
19 ms 14700 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <climits>
#include <vector>
#include <queue>
#include <utility>
#include <iomanip>
#include <cstring>
#include <fstream>

using namespace std;

typedef unsigned long long ll;
typedef pair<ll, ll> ii;

ll maks = LLONG_MAX;

ll nnad2(ll n){
    return n*(n-1)/2;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, k;
    cin >> n >> m >> k;
    ll a[n], b[m];
    ll sum = 0;
    for (ll i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
        if (a[i] < k){
            cout << "Impossible";
            return 0;
        }
    }
    for (ll i = 0; i < m; i++)
        cin >> b[i];
    
    if (k > m){
        cout << "Impossible";
        return 0;
    }
    
    vector<ll> dp(900001, -1e10);
    dp[0] = 0;
    for (ll i = 0; i < m; i++){
        for (ll j = 900000 - b[i]; j >= 0 ; j--){
            dp[j + b[i]] = max(dp[j + b[i]], dp[j] + min(n, b[i]));
        }
    }
    
    for (ll i = sum; i < 30; i++){
        if (dp[i] >= n*k){
            cout << i - sum << endl;
            return 0;
        }
    }
    cout << "Impossible";
    return 0;

}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:48:27: warning: overflow in conversion from 'double' to 'std::vector<long long unsigned int>::value_type' {aka 'long long unsigned int'} changes value from '-1.0e+10' to '0' [-Woverflow]
   48 |     vector<ll> dp(900001, -1e10);
      |                           ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 14700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 14700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 14700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 14700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 14700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -