답안 #598786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598786 2022-07-19T05:03:25 Z denniskim Intercastellar (JOI22_ho_t1) C++17
100 / 100
88 ms 10672 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef long double ld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second

ll n;
ll a[200010];
ll nu[200010];
ll fn[200010];
ll q;
ll x;
ll p;

int main(void)
{
	scanf("%lld", &n);
	
	for(ll i = 1 ; i <= n ; i++)
		scanf("%lld", &a[i]);
	
	for(ll i = 1 ; i <= n ; i++)
	{
		ll gap = a[i];
		ll cou = 1;
		
		while(gap % 2 == 0)
		{
			gap /= 2;
			cou *= 2;
		}
		
		fn[i] = gap;
		nu[i] = nu[i - 1] + cou;
	}
	
	scanf("%lld", &q);
	
	while(q--)
	{
		scanf("%lld", &x);
		
		while(p <= n && nu[p] < x)
			p++;
		
		printf("%lld\n", fn[p]);
	}
	
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%lld", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
Main.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |  scanf("%lld", &q);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |   scanf("%lld", &x);
      |   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 24 ms 5460 KB Output is correct
4 Correct 34 ms 2672 KB Output is correct
5 Correct 56 ms 7004 KB Output is correct
6 Correct 36 ms 5284 KB Output is correct
7 Correct 69 ms 7044 KB Output is correct
8 Correct 65 ms 7116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 24 ms 5460 KB Output is correct
4 Correct 34 ms 2672 KB Output is correct
5 Correct 56 ms 7004 KB Output is correct
6 Correct 36 ms 5284 KB Output is correct
7 Correct 69 ms 7044 KB Output is correct
8 Correct 65 ms 7116 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 300 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 32 ms 3192 KB Output is correct
24 Correct 39 ms 6320 KB Output is correct
25 Correct 70 ms 10292 KB Output is correct
26 Correct 46 ms 6508 KB Output is correct
27 Correct 45 ms 6584 KB Output is correct
28 Correct 83 ms 10672 KB Output is correct
29 Correct 87 ms 10252 KB Output is correct
30 Correct 46 ms 3896 KB Output is correct
31 Correct 88 ms 10648 KB Output is correct