Submission #526826

# Submission time Handle Problem Language Result Execution time Memory
526826 2022-02-16T08:24:46 Z abc864197532 Intercastellar (JOI22_ho_t1) C++17
100 / 100
83 ms 7492 KB
#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';
	}
}

Compilation message

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 time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 19 ms 2740 KB Output is correct
4 Correct 38 ms 1860 KB Output is correct
5 Correct 57 ms 3452 KB Output is correct
6 Correct 26 ms 2888 KB Output is correct
7 Correct 49 ms 3516 KB Output is correct
8 Correct 45 ms 4156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 19 ms 2740 KB Output is correct
4 Correct 38 ms 1860 KB Output is correct
5 Correct 57 ms 3452 KB Output is correct
6 Correct 26 ms 2888 KB Output is correct
7 Correct 49 ms 3516 KB Output is correct
8 Correct 45 ms 4156 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 25 ms 2644 KB Output is correct
24 Correct 41 ms 3796 KB Output is correct
25 Correct 69 ms 6636 KB Output is correct
26 Correct 39 ms 4292 KB Output is correct
27 Correct 56 ms 4024 KB Output is correct
28 Correct 79 ms 7492 KB Output is correct
29 Correct 83 ms 6516 KB Output is correct
30 Correct 38 ms 3516 KB Output is correct
31 Correct 76 ms 7396 KB Output is correct