답안 #1078616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078616 2024-08-27T23:13:18 Z quangminh412 Intercastellar (JOI22_ho_t1) C++14
100 / 100
55 ms 10852 KB
#include <bits/stdc++.h>
using namespace std;

/*
  John Watson
  https://codeforces.com/profile/quangminh98

  Mua Code nhu mua Florentino !!
*/

#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

const int maxn = 2e5 + 9;

int n, q;
ll a[maxn];
pair<int, ll> b[maxn];

pair<int, ll> compute(int x)
{
	ll p = 1;
	
	while (x % 2 == 0)
	{
		p = p * 2;
		x /= 2;
	}
	
	return {x, p};
}

signed main()
{
	if (fopen("test.inp", "r"))
	{
		freopen("test.inp", "r", stdin);
		freopen("test.out", "w", stdout);
	}
	faster();

	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		b[i] = compute(a[i]);
	}
	for (int i = 1; i <= n; i++)
		a[i] = a[i - 1] + b[i].second;

	cin >> q;
	while (q--)
	{
		ll x; cin >> x;
		
		int pos = lower_bound(a + 1, a + n + 1, x) - a;
		
		cout << b[pos].first << '\n';
	}

	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:37:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   freopen("test.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:38:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   freopen("test.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 13 ms 5720 KB Output is correct
4 Correct 19 ms 5972 KB Output is correct
5 Correct 35 ms 7252 KB Output is correct
6 Correct 20 ms 5976 KB Output is correct
7 Correct 33 ms 7252 KB Output is correct
8 Correct 37 ms 7280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 13 ms 5720 KB Output is correct
4 Correct 19 ms 5972 KB Output is correct
5 Correct 35 ms 7252 KB Output is correct
6 Correct 20 ms 5976 KB Output is correct
7 Correct 33 ms 7252 KB Output is correct
8 Correct 37 ms 7280 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 20 ms 6740 KB Output is correct
24 Correct 23 ms 7260 KB Output is correct
25 Correct 44 ms 10456 KB Output is correct
26 Correct 31 ms 8028 KB Output is correct
27 Correct 30 ms 7772 KB Output is correct
28 Correct 55 ms 10852 KB Output is correct
29 Correct 48 ms 10320 KB Output is correct
30 Correct 25 ms 7508 KB Output is correct
31 Correct 52 ms 10832 KB Output is correct