답안 #798306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798306 2023-07-30T15:08:34 Z n3rm1n Intercastellar (JOI22_ho_t1) C++17
100 / 100
89 ms 12316 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 2e5 + 10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n, q;
long long a[MAXN];
long long r[MAXN], cnt[MAXN], pref[MAXN];
void read()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
        r[i] = a[i];
        while(r[i] % (1LL * 2) == 0)
            r[i] /= (1LL * 2);
        cnt[i] = a[i] / r[i];
        pref[i] = pref[i-1] + cnt[i];
    }
   // for (int i = 1; i <= n; ++ i)
       // cout << r[i] << " " << cnt[i] << " " << pref[i] << endl;
}

long long x;
void solve_query()
{
    int left = 0, right = n, mid, ans = 0;
    while(left <= right)
    {
        mid = (left + right)/2;
        if(pref[mid] < x)
        {
            ans = mid;
            left = mid + 1;
        }
        else right = mid - 1;
    }
    ans ++;
    cout << r[ans] << endl;
}
void queries()
{
    cin >> q;
    while(q --)
    {
        cin >> x;
        solve_query();
    }
}
int main()
{
    speed();

    read();
    queries();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 16 ms 6996 KB Output is correct
4 Correct 26 ms 3120 KB Output is correct
5 Correct 45 ms 8616 KB Output is correct
6 Correct 24 ms 6672 KB Output is correct
7 Correct 41 ms 8588 KB Output is correct
8 Correct 40 ms 8660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 336 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 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 396 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 0 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 16 ms 6996 KB Output is correct
4 Correct 26 ms 3120 KB Output is correct
5 Correct 45 ms 8616 KB Output is correct
6 Correct 24 ms 6672 KB Output is correct
7 Correct 41 ms 8588 KB Output is correct
8 Correct 40 ms 8660 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 336 KB Output is correct
14 Correct 1 ms 336 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 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 396 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 23 ms 3576 KB Output is correct
24 Correct 28 ms 7412 KB Output is correct
25 Correct 55 ms 11892 KB Output is correct
26 Correct 36 ms 7532 KB Output is correct
27 Correct 40 ms 7752 KB Output is correct
28 Correct 72 ms 12316 KB Output is correct
29 Correct 89 ms 11796 KB Output is correct
30 Correct 32 ms 4144 KB Output is correct
31 Correct 68 ms 12192 KB Output is correct