제출 #1129169

#제출 시각아이디문제언어결과실행 시간메모리
1129169yumemysteryIntercastellar (JOI22_ho_t1)C++20
100 / 100
64 ms5448 KiB
#include <iostream> #include <cmath> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; unsigned long long A[n]; //len unsigned long long total_castella[n]; for (int i=0; i<n; i++) { cin >> A[i]; unsigned long long tmp = A[i]; while (tmp%2 == 0) tmp/=2; total_castella[i] = A[i]/tmp; A[i] = tmp; if (i>0) total_castella[i]+=total_castella[i-1]; } int Q; cin >> Q; for (int i=0; i<Q; i++) { unsigned long long x; cin >> x; int left = 0; int right = n-1; int ans = 0; while (left<=right) { int mid = left+(right-left)/2; if (total_castella[mid] > x) { ans = mid; right = mid-1; } else if (total_castella[mid] == x) { ans = mid; break; } else left = mid+1; } cout << A[ans] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...