1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    int items[n],bags[m],max_item = 0,max_bag = 0,all_items = 0;
    for (int i = 0; i < n; i++) {
        cin >> items[i];
        if (items[i]>max_item) {
            max_item = items[i];
        }
        all_items += items[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> bags[i];
        if (bags[i]>max_bag) {
            max_bag = bags[i];
        }
    }
    if (max_item>max_bag) {
        cout << "NIE";
    }
    else {
        if (all_items%max_bag==0) {
            cout << all_items/max_bag;
        }
        else {
            cout << all_items/max_bag+1;
        }
    }
    return 0;
}