답안 #87772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87772 2018-12-02T11:58:12 Z JustInCase Brunhilda’s Birthday (BOI13_brunhilda) C++17
40 / 100
1000 ms 1236 KB
#include <bits/stdc++.h>

const int32_t MAX_N = 1e7;
const int32_t MAX_M = 1e5;

int32_t p[MAX_M + 5];

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int32_t m, q;
	std::cin >> m >> q;

	int64_t lcm = 1;
	int32_t maxP;
	for(int32_t i = 0; i < m; i++) {
		std::cin >> p[i];

		if(lcm <= MAX_N) {
			lcm *= (int64_t) p[i];
		}
	}

	std::sort(p, p + m);

	for(int32_t i = 0; i < q; i++) {
		int32_t n;
		std::cin >> n;

		if(n >= lcm) {
			std::cout << "oo" << '\n';
		}
		else {
			int32_t ans = 0;
			while(n > 0) {
				int32_t curr = 0;
				for(int32_t j = m - 1; j >= 0; j--) {
					curr = std::max(curr, n % p[j]);
				}
				ans++;
				n -= curr;
			}

			std::cout << ans << '\n';
		}
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:16:10: warning: unused variable 'maxP' [-Wunused-variable]
  int32_t maxP;
          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 508 KB Output is correct
3 Correct 1 ms 508 KB Output is correct
4 Correct 9 ms 676 KB Output is correct
5 Correct 3 ms 676 KB Output is correct
6 Correct 4 ms 696 KB Output is correct
7 Correct 3 ms 696 KB Output is correct
8 Correct 3 ms 696 KB Output is correct
9 Correct 2 ms 696 KB Output is correct
10 Correct 6 ms 696 KB Output is correct
11 Correct 9 ms 696 KB Output is correct
12 Correct 3 ms 696 KB Output is correct
13 Correct 7 ms 696 KB Output is correct
14 Correct 37 ms 708 KB Output is correct
15 Correct 3 ms 764 KB Output is correct
16 Correct 3 ms 764 KB Output is correct
17 Correct 32 ms 764 KB Output is correct
18 Correct 10 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 796 KB Output is correct
2 Correct 22 ms 1052 KB Output is correct
3 Correct 11 ms 1052 KB Output is correct
4 Correct 3 ms 1052 KB Output is correct
5 Correct 9 ms 1052 KB Output is correct
6 Correct 3 ms 1052 KB Output is correct
7 Correct 4 ms 1052 KB Output is correct
8 Correct 3 ms 1052 KB Output is correct
9 Correct 12 ms 1196 KB Output is correct
10 Correct 12 ms 1196 KB Output is correct
11 Correct 10 ms 1196 KB Output is correct
12 Correct 4 ms 1196 KB Output is correct
13 Correct 3 ms 1196 KB Output is correct
14 Correct 4 ms 1196 KB Output is correct
15 Correct 8 ms 1196 KB Output is correct
16 Correct 15 ms 1196 KB Output is correct
17 Correct 7 ms 1196 KB Output is correct
18 Correct 17 ms 1200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1068 ms 1200 KB Time limit exceeded
2 Execution timed out 1055 ms 1200 KB Time limit exceeded
3 Execution timed out 1033 ms 1200 KB Time limit exceeded
4 Execution timed out 1062 ms 1200 KB Time limit exceeded
5 Execution timed out 1062 ms 1200 KB Time limit exceeded
6 Execution timed out 1048 ms 1200 KB Time limit exceeded
7 Execution timed out 1079 ms 1200 KB Time limit exceeded
8 Execution timed out 1075 ms 1200 KB Time limit exceeded
9 Execution timed out 1063 ms 1200 KB Time limit exceeded
10 Execution timed out 1068 ms 1200 KB Time limit exceeded
11 Execution timed out 1058 ms 1200 KB Time limit exceeded
12 Execution timed out 1067 ms 1200 KB Time limit exceeded
13 Execution timed out 1060 ms 1200 KB Time limit exceeded
14 Execution timed out 1075 ms 1200 KB Time limit exceeded
15 Execution timed out 1046 ms 1200 KB Time limit exceeded
16 Execution timed out 1085 ms 1200 KB Time limit exceeded
17 Execution timed out 1069 ms 1200 KB Time limit exceeded
18 Execution timed out 1063 ms 1200 KB Time limit exceeded
19 Execution timed out 1079 ms 1200 KB Time limit exceeded
20 Execution timed out 1072 ms 1200 KB Time limit exceeded
21 Execution timed out 1054 ms 1200 KB Time limit exceeded
22 Execution timed out 1078 ms 1216 KB Time limit exceeded
23 Execution timed out 1072 ms 1216 KB Time limit exceeded
24 Execution timed out 1082 ms 1216 KB Time limit exceeded
25 Execution timed out 1063 ms 1216 KB Time limit exceeded
26 Execution timed out 1076 ms 1216 KB Time limit exceeded
27 Execution timed out 1016 ms 1216 KB Time limit exceeded
28 Execution timed out 1062 ms 1216 KB Time limit exceeded
29 Execution timed out 1031 ms 1216 KB Time limit exceeded
30 Execution timed out 1044 ms 1216 KB Time limit exceeded
31 Execution timed out 1020 ms 1216 KB Time limit exceeded
32 Execution timed out 1036 ms 1216 KB Time limit exceeded
33 Execution timed out 1074 ms 1216 KB Time limit exceeded
34 Execution timed out 1071 ms 1216 KB Time limit exceeded
35 Execution timed out 1077 ms 1216 KB Time limit exceeded
36 Execution timed out 1083 ms 1216 KB Time limit exceeded
37 Execution timed out 1059 ms 1216 KB Time limit exceeded
38 Execution timed out 1036 ms 1216 KB Time limit exceeded
39 Execution timed out 1092 ms 1216 KB Time limit exceeded
40 Execution timed out 1082 ms 1216 KB Time limit exceeded
41 Execution timed out 1051 ms 1236 KB Time limit exceeded
42 Execution timed out 1053 ms 1236 KB Time limit exceeded