답안 #800248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800248 2023-08-01T12:44:45 Z caganyanmaz Intercastellar (JOI22_ho_t1) C++17
100 / 100
422 ms 10700 KB
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

constexpr static int MXSIZE = 2e5;
int v[MXSIZE], prefix[MXSIZE+1], f[MXSIZE];

int32_t main()
{
        int n;
        cin >> n;
        for (int i = 0; i < n; i++)
                cin >> v[i];
        for (int i = 0; i < n; i++)
        {
                f[i] = v[i];
                int c = 1;
                while (!(f[i]&1))
                {
                        c <<= 1;
                        f[i] >>= 1;
                }
                prefix[i+1] = c;
        }
        for (int i = 1; i <= n; i++)
                prefix[i] += prefix[i-1];
        int q;
        cin >> q;
        while (q--)
        {
                int qq;
                cin >> qq;
                int l = 0, r = n+1;
                while (r - l > 1)
                {
                        int m = l+r>>1;
                        if (prefix[m] >= qq)
                                r = m;
                        else
                                l = m;
                }
                cout << f[l] << "\n";
        }

}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:36:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   36 |                         int m = l+r>>1;
      |                                 ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 80 ms 5484 KB Output is correct
4 Correct 202 ms 2656 KB Output is correct
5 Correct 301 ms 7060 KB Output is correct
6 Correct 147 ms 5376 KB Output is correct
7 Correct 294 ms 7112 KB Output is correct
8 Correct 295 ms 7180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 2 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 80 ms 5484 KB Output is correct
4 Correct 202 ms 2656 KB Output is correct
5 Correct 301 ms 7060 KB Output is correct
6 Correct 147 ms 5376 KB Output is correct
7 Correct 294 ms 7112 KB Output is correct
8 Correct 295 ms 7180 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 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 2 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 177 ms 3488 KB Output is correct
24 Correct 163 ms 6244 KB Output is correct
25 Correct 422 ms 10328 KB Output is correct
26 Correct 199 ms 6516 KB Output is correct
27 Correct 166 ms 6592 KB Output is correct
28 Correct 409 ms 10700 KB Output is correct
29 Correct 357 ms 10260 KB Output is correct
30 Correct 240 ms 3944 KB Output is correct
31 Correct 355 ms 10644 KB Output is correct