제출 #526826

#제출 시각아이디문제언어결과실행 시간메모리
526826abc864197532Intercastellar (JOI22_ho_t1)C++17
100 / 100
83 ms7492 KiB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
	cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
	for (; l != r; ++l) cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x)
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(x...) void(0)
#define owo ios::sync_with_stdio(false), cin.tie(0);
#endif
const int N = 200000;

int main () {
	owo;
	int n;
	cin >> n;
	vector <pii> a;
	for (int i = 0, x; i < n; ++i) {
		cin >> x;
		int now = 1;
		while (x & 1 ^ 1)
			now <<= 1, x >>= 1;
		a.eb(x, now);
	}
	int q;
	cin >> q;
	int now = 0;
	lli sum = 0;
	while (q--) {
		lli x;
		cin >> x;
		while (now < n && sum + a[now].Y < x)
			sum += a[now].Y, now++;
		cout << a[now].X << '\n';
	}
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:35:12: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   35 |   while (x & 1 ^ 1)
      |          ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...