답안 #631282

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
631282 2022-08-18T02:32:10 Z TranGiaHuy1508 Brunhilda’s Birthday (BOI13_brunhilda) C++17
20 / 100
1000 ms 1120 KB
/*
	Unknown's C++ Template (v3.2)
*/

#include "bits/stdc++.h"
using namespace std;

#define int long long

using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;
template <class T> using maxpq = priority_queue<T>;
template <class T> using minpq = priority_queue<T, vector<T>, greater<T>>;

#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mid ((l+r)>>1)
#define fi first
#define se second

#ifdef LOCAL
	#define debug(x) cout << #x << " = " << x << "\n";
#else
	#define debug(x) ;
#endif

template <class A, class B>
ostream& operator << (ostream& out, pair<A, B> x)
{ out << "(" << x.first << ", " << x.second << ")"; return out; }

template <class T>
ostream& operator << (ostream& out, vector<T> x){
	out << "[";
	for (int i=0; i<sz(x); i++) { out << (i ? ", " : "") << x[i]; }
	out << "]"; return out;
}

template <class T>
istream& operator >> (istream& in, vector<T> &x){
	for (auto &i: x) in >> i;
	return in;
}

const ld PI = acos(-1.0);
const int allmod[3] = {(int)1e9+7, 998244353, (int)1e9+9};
const int mod = allmod[0];
const int maxn = 2e5 + 64;
const ll inf = 1e18;
const ld eps = 1e-6;
const int multitest = 0;

void main_program(){
	int m, q; cin >> m >> q;
	vi v(m); cin >> v;

	vi dp(1e4 + 10, inf);
	dp[0] = 0;
	for (int i = 1; i < 1e4 + 10; i++){
		for (auto j: v){
			if (i - (i % j) < i) dp[i] = min(dp[i], dp[i - (i % j)] + 1);
		}
	}

	for (int i = 0; i < q; i++){
		int x; cin >> x;
		if (dp[x] == inf) cout << "oo\n";
		else cout << dp[x] << "\n";
	}
}

void pre_main(){

}

signed main(){
	#ifdef LOCAL
		auto stime = chrono::high_resolution_clock::now();
	#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
		if (fopen(".inp", "r")){
			freopen(".inp", "r", stdin);
			freopen(".out", "w", stdout);
		}
	#endif
	int t = 1; if (multitest) cin >> t;
	pre_main();
	while (t--) main_program();
	#ifdef LOCAL
		auto etime = chrono::high_resolution_clock::now();
		auto duration = chrono::duration_cast<chrono::milliseconds>(etime-stime).count();
		cout << "\n[" << duration << "ms]\n";
	#endif
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:88:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   88 |    freopen(".inp", "r", stdin);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~
brunhilda.cpp:89:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |    freopen(".out", "w", stdout);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 400 KB Output is correct
12 Correct 6 ms 340 KB Output is correct
13 Correct 50 ms 340 KB Output is correct
14 Correct 50 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 6 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 572 ms 724 KB Execution killed with signal 11
2 Execution timed out 1097 ms 1108 KB Time limit exceeded
3 Execution timed out 1045 ms 852 KB Time limit exceeded
4 Runtime error 147 ms 528 KB Execution killed with signal 11
5 Execution timed out 1085 ms 724 KB Time limit exceeded
6 Runtime error 58 ms 588 KB Execution killed with signal 11
7 Runtime error 556 ms 736 KB Execution killed with signal 11
8 Runtime error 48 ms 588 KB Execution killed with signal 11
9 Execution timed out 1090 ms 852 KB Time limit exceeded
10 Execution timed out 1088 ms 852 KB Time limit exceeded
11 Execution timed out 1092 ms 724 KB Time limit exceeded
12 Runtime error 99 ms 524 KB Execution killed with signal 11
13 Runtime error 134 ms 524 KB Execution killed with signal 11
14 Runtime error 143 ms 540 KB Execution killed with signal 11
15 Execution timed out 1092 ms 724 KB Time limit exceeded
16 Execution timed out 1071 ms 1108 KB Time limit exceeded
17 Runtime error 142 ms 532 KB Execution killed with signal 11
18 Execution timed out 1084 ms 1108 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 724 KB Time limit exceeded
2 Execution timed out 1080 ms 724 KB Time limit exceeded
3 Execution timed out 1098 ms 724 KB Time limit exceeded
4 Runtime error 158 ms 532 KB Execution killed with signal 11
5 Execution timed out 1094 ms 1108 KB Time limit exceeded
6 Runtime error 374 ms 700 KB Execution killed with signal 11
7 Execution timed out 1092 ms 1108 KB Time limit exceeded
8 Execution timed out 1096 ms 724 KB Time limit exceeded
9 Execution timed out 1096 ms 724 KB Time limit exceeded
10 Runtime error 283 ms 680 KB Execution killed with signal 11
11 Runtime error 203 ms 552 KB Execution killed with signal 11
12 Runtime error 274 ms 688 KB Execution killed with signal 11
13 Execution timed out 1086 ms 564 KB Time limit exceeded
14 Runtime error 3 ms 596 KB Execution killed with signal 11
15 Runtime error 260 ms 688 KB Execution killed with signal 11
16 Runtime error 323 ms 696 KB Execution killed with signal 11
17 Execution timed out 1045 ms 724 KB Time limit exceeded
18 Execution timed out 1090 ms 724 KB Time limit exceeded
19 Runtime error 234 ms 672 KB Execution killed with signal 11
20 Execution timed out 1095 ms 724 KB Time limit exceeded
21 Runtime error 6 ms 596 KB Execution killed with signal 11
22 Execution timed out 1086 ms 1120 KB Time limit exceeded
23 Execution timed out 1093 ms 596 KB Time limit exceeded
24 Runtime error 52 ms 528 KB Execution killed with signal 11
25 Runtime error 137 ms 524 KB Execution killed with signal 11
26 Runtime error 156 ms 544 KB Execution killed with signal 11
27 Execution timed out 1096 ms 1108 KB Time limit exceeded
28 Runtime error 49 ms 588 KB Execution killed with signal 11
29 Execution timed out 1066 ms 1112 KB Time limit exceeded
30 Execution timed out 1084 ms 852 KB Time limit exceeded
31 Runtime error 203 ms 672 KB Execution killed with signal 11
32 Runtime error 144 ms 524 KB Execution killed with signal 11
33 Runtime error 62 ms 524 KB Execution killed with signal 11
34 Execution timed out 1087 ms 1108 KB Time limit exceeded
35 Runtime error 93 ms 588 KB Execution killed with signal 11
36 Execution timed out 1082 ms 1108 KB Time limit exceeded
37 Execution timed out 1087 ms 1108 KB Time limit exceeded
38 Runtime error 374 ms 704 KB Execution killed with signal 11
39 Runtime error 110 ms 524 KB Execution killed with signal 11
40 Runtime error 436 ms 708 KB Execution killed with signal 11
41 Execution timed out 1083 ms 1120 KB Time limit exceeded
42 Runtime error 140 ms 664 KB Execution killed with signal 11