답안 #625116

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625116 2022-08-09T11:55:19 Z iomoon191 Intercastellar (JOI22_ho_t1) C++17
100 / 100
75 ms 10916 KB
#include <bits/stdc++.h>
using ll = long long;
#define int ll
using namespace std;

#define sz(x) (int)(x).size()
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, l, r) for(int i = l; i >= r; i--)
#define fi first
#define se second
#define mod 998244353

#define db(x) cerr << __LINE__ << " " << #x << " " << x << "\n"
using vi = vector<int>;
using pi = pair<int, int>;

const ll N = 200005;
const ll inf = 1e18;

int n, a[N];
vector<pi> v;

void solve(){
	cin >> n;
	foru(i, 1, n){
		cin >> a[i];
		int c = 1;
		while(a[i] % 2 == 0){
			a[i] >>= 1;
			c <<= 1;
		}
		v.push_back(pi(c, a[i]));
	}
	int sum = 0, z = 0;
	int q; cin >> q;
	while(q--){
		int x; cin >> x;
		while(z < n and sum + v[z].fi < x){
			sum += v[z].fi;
			z++;
		}
		cout << v[z].se << "\n";
	}
}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int t = 1; 
	while(t--){
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 20 ms 6092 KB Output is correct
4 Correct 24 ms 2816 KB Output is correct
5 Correct 44 ms 7204 KB Output is correct
6 Correct 27 ms 6092 KB Output is correct
7 Correct 53 ms 7272 KB Output is correct
8 Correct 49 ms 7268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 20 ms 6092 KB Output is correct
4 Correct 24 ms 2816 KB Output is correct
5 Correct 44 ms 7204 KB Output is correct
6 Correct 27 ms 6092 KB Output is correct
7 Correct 53 ms 7272 KB Output is correct
8 Correct 49 ms 7268 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 324 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 23 ms 3444 KB Output is correct
24 Correct 33 ms 7056 KB Output is correct
25 Correct 59 ms 10424 KB Output is correct
26 Correct 45 ms 6732 KB Output is correct
27 Correct 39 ms 7084 KB Output is correct
28 Correct 71 ms 10916 KB Output is correct
29 Correct 72 ms 10340 KB Output is correct
30 Correct 36 ms 4024 KB Output is correct
31 Correct 75 ms 10796 KB Output is correct