답안 #527561

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527561 2022-02-17T16:18:21 Z SilentVisitor Intercastellar (JOI22_ho_t1) C++17
100 / 100
93 ms 6204 KB
#include<bits/stdc++.h> 
using namespace std; 

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin() c.rend()

const int N = 200010; 
int n, q, a[N]; 
long long pre[N];  
void solve(){
	  scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        int o = a[i];
        while (!(a[i] % 2)) a[i] /= 2;
        pre[i] = pre[i - 1] + o / a[i];
    }
    scanf("%d", &q);
    while (q--) {
        long long x;
        scanf("%lld", &x);
        int i = lower_bound(pre + 1, pre + n + 1, x) - pre;
        printf("%d\n", a[i]);
    }
}
int main(){
	 ios::sync_with_stdio(false); 
	 cin.tie(0); 
	 cout.tie(0); 
	 solve(); 
	 return 0; 
}
/*
Task 1 : 
16
536870912
402653184
536870912
536870912
134217728
536870912
671088640
536870912
536870912
536870912
939524096
805306368
536870912
956301312
536870912
536870912
5
2500000000
3355443201
4294967296
5111111111
6190792704
Sample output for the following :-> 
5
1
7
57
1

Task 2 : 
4
14
9
8
12
6
2
3
5
7
11
13
Output for the following input : 
7
9
1
1
1
3

Task 3 :->
13
1
4
1
4
2
1
3
5
6
2
3
7
3
8
2
10
11
13
15
17
18
20
Sample output for the following :-> 
1
1
1
1
5
3
1
3
*/

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:11:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |    scanf("%d", &n);
      |    ~~~~~^~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
Main.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%lld", &x);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 26 ms 2612 KB Output is correct
4 Correct 38 ms 1888 KB Output is correct
5 Correct 65 ms 4216 KB Output is correct
6 Correct 41 ms 3396 KB Output is correct
7 Correct 67 ms 4244 KB Output is correct
8 Correct 65 ms 4660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 26 ms 2612 KB Output is correct
4 Correct 38 ms 1888 KB Output is correct
5 Correct 65 ms 4216 KB Output is correct
6 Correct 41 ms 3396 KB Output is correct
7 Correct 67 ms 4244 KB Output is correct
8 Correct 65 ms 4660 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 328 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 34 ms 2644 KB Output is correct
24 Correct 39 ms 4204 KB Output is correct
25 Correct 78 ms 6204 KB Output is correct
26 Correct 54 ms 4036 KB Output is correct
27 Correct 53 ms 4056 KB Output is correct
28 Correct 91 ms 5340 KB Output is correct
29 Correct 93 ms 4772 KB Output is correct
30 Correct 49 ms 2932 KB Output is correct
31 Correct 91 ms 5128 KB Output is correct