답안 #1017708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1017708 2024-07-09T09:36:08 Z FIFI_cpp Intercastellar (JOI22_ho_t1) C++17
100 / 100
389 ms 10836 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cctype>
#include <string>
#include <cassert>
#include <set>
#include <bitset>
#include <unordered_set>
using ll = int64_t;
#define pb push_back
#define all(a) a.begin(),a.end()
#define ppi pair<pair<int,int>,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int int64_t
// xcode cant include bits/stdc++.h
using namespace std;
//ifstream fin ("sleepy.in");
//ofstream fout ("sleepy.out");
/*   /\_/\
*   (= ._.)
*   / >  \>
*/
// encouraging cat
const int INF = 10000000000000000;
const int mod = 1000000007;
int32_t main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    vector<int> pref(n,0);
    vector<int> val(n,0);
    int s = 0;
    int v = 1;
    for (int i = 0;i < n;i++)
    {
        val[i] = a[i] / (a[i] & (-a[i]));
        s += a[i] & (-a[i]);
        pref[i] = s;
        
    }
    int q;
    cin >> q;
    while (q--)
    {
        int x;
        cin >> x;
        int lo = 0,hi = n - 1;
        while (lo < hi)
        {
            int mid = (lo + hi) / 2;
            if (pref[mid] < x)
                lo = mid + 1;
            else
                hi = mid;
        }
        cout << val[hi] << '\n';
    }
    return 0;
}

Compilation message

Main.cpp:32:9: warning: "/*" within comment [-Wcomment]
   32 | /*   /\_/\
      |          
Main.cpp: In function 'int32_t main()':
Main.cpp:50:9: warning: unused variable 'v' [-Wunused-variable]
   50 |     int v = 1;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 64 ms 5636 KB Output is correct
4 Correct 188 ms 2748 KB Output is correct
5 Correct 268 ms 7248 KB Output is correct
6 Correct 141 ms 5456 KB Output is correct
7 Correct 271 ms 7224 KB Output is correct
8 Correct 288 ms 7248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 64 ms 5636 KB Output is correct
4 Correct 188 ms 2748 KB Output is correct
5 Correct 268 ms 7248 KB Output is correct
6 Correct 141 ms 5456 KB Output is correct
7 Correct 271 ms 7224 KB Output is correct
8 Correct 288 ms 7248 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 440 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 174 ms 3408 KB Output is correct
24 Correct 139 ms 6336 KB Output is correct
25 Correct 304 ms 10316 KB Output is correct
26 Correct 185 ms 6484 KB Output is correct
27 Correct 151 ms 6668 KB Output is correct
28 Correct 329 ms 10712 KB Output is correct
29 Correct 329 ms 10324 KB Output is correct
30 Correct 226 ms 3920 KB Output is correct
31 Correct 389 ms 10836 KB Output is correct