제출 #777082

#제출 시각아이디문제언어결과실행 시간메모리
777082LinkedArrayIntercastellar (JOI22_ho_t1)C++17
100 / 100
66 ms6860 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5; int a[MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, q, i, pnt; long long p2 = 0, x; cin >> n; for(i = 0; i < n; i++){ cin >> a[i]; } cin >> q; pnt = -1; // We start from -1, since we want our first pnt to be 0 (x + 1 = 0 => x = 0 - 1 => x = -1) for(i = 0; i < q; i++){ cin >> x; while(p2 < x){ ++pnt; // Update our pointer long long put2 = 1; while(a[pnt] % 2 == 0){ // While our number is still divisible with 2 a[pnt] /= 2; // Divide put2 *= 2; // and update our power } // This means that now put2 * a[pnt] = original a[pnt] p2 += put2; // And we just add this value to our total one } cout << a[pnt] << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...