제출 #703567

#제출 시각아이디문제언어결과실행 시간메모리
703567Jeff12345121Intercastellar (JOI22_ho_t1)C++14
0 / 100
2062 ms1684 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL ifstream in("in.in"); ofstream out("out.out"); #else #define in cin #define out cout #endif const int nmax = 200005; int n,a[nmax],q; pair<int,int> get_nr(int x) { int nr = 1; while(x%2 == 0) { nr = nr * 2; x /= 2; } return {nr,x}; } int answer(int x) { for (int i = 1; i <= n; i++) { auto val = get_nr(a[i]); if (val.first < x) { x -= val.first; } else { return val.second; } } return -1; } int main() { in >> n; for (int i = 1; i <= n; i++) { in >> a[i]; } in >> q; for (int i = 1; i <= q; i++) { int x; in >> x; out << answer(x) << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...