답안 #472987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472987 2021-09-14T17:37:33 Z hidden1 Brunhilda’s Birthday (BOI13_brunhilda) C++14
59.6825 / 100
1000 ms 2500 KB
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;}
template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;}
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
#define debug(...) cout << "Line: " << __LINE__ << endl; \
    printDebug(", "#__VA_ARGS__, __VA_ARGS__)
template <typename T>
void printDebug(const char* name, T&& arg1) { cout << (name + 2) << " = " << arg1 << endl; }
template <typename T, typename... T2>
void printDebug(const char* names, T&& arg1, T2&&... args) {
    const char* end = strchr(names + 1, ',');
    cout.write(names + 2, end - names - 2) << " = " << arg1 << endl;
    printDebug(end, args...);
}

const int MAX_N = 1e5 + 10;
vector<int> arr;
int n, q;

const int MAX_Q = 1e8 + 10;
int dp[MAX_Q];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> q;
    arr.resize(n);
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
    }

    sort(arr.begin(), arr.end());
    arr.resize(unique(arr.begin(), arr.end()) - arr.begin());

    while(q --) {
        int now;
        int cnt = 0;
        cin >> now;
        while(now) {
            int best = 0;
            for(int i = n - 1; i >= max(0, n - 20); i --) {
                chkmax(best, now % arr[i]);
            }
            if(best == 0) {
                cout << "oo" << endl;
                break;
            }
            now -= best;
            cnt ++;
        }
        if(!now) {
            cout << cnt << endl;
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 4 ms 332 KB Output isn't correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 5 ms 324 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 11 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 15 ms 332 KB Output is correct
18 Incorrect 4 ms 332 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 12 ms 1312 KB Output is correct
3 Correct 9 ms 972 KB Output is correct
4 Incorrect 1 ms 332 KB Output isn't correct
5 Correct 9 ms 772 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Correct 12 ms 976 KB Output is correct
10 Correct 9 ms 984 KB Output is correct
11 Incorrect 7 ms 716 KB Output isn't correct
12 Incorrect 1 ms 332 KB Output isn't correct
13 Correct 1 ms 332 KB Output is correct
14 Incorrect 1 ms 332 KB Output isn't correct
15 Correct 6 ms 736 KB Output is correct
16 Correct 17 ms 1320 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Incorrect 13 ms 1356 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 1208 KB Output is correct
2 Correct 33 ms 1100 KB Output is correct
3 Correct 90 ms 1412 KB Output is correct
4 Incorrect 588 ms 1228 KB Output isn't correct
5 Correct 70 ms 2500 KB Output is correct
6 Incorrect 488 ms 1344 KB Output isn't correct
7 Correct 48 ms 1860 KB Output is correct
8 Correct 52 ms 1164 KB Output is correct
9 Correct 52 ms 1220 KB Output is correct
10 Incorrect 77 ms 476 KB Output isn't correct
11 Incorrect 152 ms 564 KB Output isn't correct
12 Incorrect 151 ms 552 KB Output isn't correct
13 Incorrect 167 ms 1584 KB Output isn't correct
14 Execution timed out 1087 ms 332 KB Time limit exceeded
15 Incorrect 210 ms 572 KB Output isn't correct
16 Incorrect 180 ms 556 KB Output isn't correct
17 Correct 18 ms 844 KB Output is correct
18 Correct 33 ms 1032 KB Output is correct
19 Correct 24 ms 548 KB Output is correct
20 Correct 87 ms 1464 KB Output is correct
21 Execution timed out 1085 ms 332 KB Time limit exceeded
22 Correct 109 ms 2372 KB Output is correct
23 Correct 127 ms 1580 KB Output is correct
24 Incorrect 643 ms 1328 KB Output isn't correct
25 Execution timed out 1095 ms 1476 KB Time limit exceeded
26 Incorrect 595 ms 1228 KB Output isn't correct
27 Correct 60 ms 1888 KB Output is correct
28 Execution timed out 1081 ms 1404 KB Time limit exceeded
29 Correct 109 ms 2368 KB Output is correct
30 Correct 129 ms 2116 KB Output is correct
31 Incorrect 201 ms 1212 KB Output isn't correct
32 Incorrect 687 ms 1212 KB Output isn't correct
33 Incorrect 299 ms 1180 KB Output isn't correct
34 Correct 49 ms 1864 KB Output is correct
35 Execution timed out 1087 ms 1436 KB Time limit exceeded
36 Correct 83 ms 2264 KB Output is correct
37 Correct 75 ms 2364 KB Output is correct
38 Incorrect 478 ms 1428 KB Output isn't correct
39 Incorrect 557 ms 1324 KB Output isn't correct
40 Incorrect 307 ms 1348 KB Output isn't correct
41 Correct 30 ms 1868 KB Output is correct
42 Execution timed out 1090 ms 916 KB Time limit exceeded