답안 #526348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526348 2022-02-14T13:08:51 Z model_code Intercastellar (JOI22_ho_t1) C++17
100 / 100
88 ms 8580 KB
#include <cstdio>

typedef long long int ll;

ll n;
ll a[1020406];
ll q;
ll b[1020406];

ll cnt[1020406];
ll acc[1020406];

int main (void) {
	ll i, j;

	scanf("%lld", &n);
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	scanf("%lld", &q);
	for (i = 0; i < q; i++) {
		scanf("%lld", &b[i]);
	}

	acc[0] = 0;
	for (i = 0; i < n; i++) {
		ll num = 1;
		while (!(a[i] & num)) num *= 2;

		cnt[i] = num;
		acc[i + 1] = acc[i] + cnt[i];
	}

	ll result;

	for (i = 0; i < q; i++) {
		ll ok = n, ng = 0;
		while (ng + 1 < ok) {
			ll med = (ok + ng) / 2;
			if (acc[med] >= b[i]) {
				ok = med;
			} else {
				ng = med;
			}
		}

		result = a[ok - 1] / cnt[ok - 1];
		printf("%lld\n", result);
	}

	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:14:8: warning: unused variable 'j' [-Wunused-variable]
   14 |  ll i, j;
      |        ^
Main.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%lld", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
Main.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%lld", &q);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%lld", &b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 28 ms 5584 KB Output is correct
4 Correct 39 ms 3460 KB Output is correct
5 Correct 68 ms 7876 KB Output is correct
6 Correct 38 ms 5336 KB Output is correct
7 Correct 66 ms 7880 KB Output is correct
8 Correct 76 ms 8488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 288 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 28 ms 5584 KB Output is correct
4 Correct 39 ms 3460 KB Output is correct
5 Correct 68 ms 7876 KB Output is correct
6 Correct 38 ms 5336 KB Output is correct
7 Correct 66 ms 7880 KB Output is correct
8 Correct 76 ms 8488 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 288 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 32 ms 3140 KB Output is correct
24 Correct 43 ms 5016 KB Output is correct
25 Correct 88 ms 8580 KB Output is correct
26 Correct 54 ms 4724 KB Output is correct
27 Correct 49 ms 4732 KB Output is correct
28 Correct 88 ms 7624 KB Output is correct
29 Correct 87 ms 6832 KB Output is correct
30 Correct 45 ms 2756 KB Output is correct
31 Correct 88 ms 7428 KB Output is correct