Submission #1087078

# Submission time Handle Problem Language Result Execution time Memory
1087078 2024-09-12T07:49:43 Z Dennis_Jason Intercastellar (JOI22_ho_t1) C++14
100 / 100
51 ms 10832 KB
#include <bitset>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <system_error>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#define pb push_back
#define MOD 1000000007
#define NMAX 200001
#define MAX 10000000
#define nl '\n'
#define pii1 pair<int, pair<int,int>>  (1,(1,2));
#define pii pair<int,int>
#define tpl tuple<int,int,int>
#define int long long
using namespace std;
ifstream fin("data.in");
ofstream fout("data.out");
const int INF=1e12;
/*
    ====================DEMONSTRATION======================


    =========================END===========================

 */
int n;
vector<int>v;
int q;
signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    v.resize(n+1);
    vector<int>aux(n+1);
    vector<int>div(n+1);
    for(int i=1;i<=n;++i)
    {
        cin>>v[i];
    }
    cin>>q;
    for(int i=1;i<=n;++i)
    {
        int num=1;
        while(!(v[i]&num))
            num*=2;
        div[i]=num;
        aux[i]+=aux[i-1]+div[i];
    }
    for(int i=1;i<=q;++i)
    {
        int x;
        cin>>x;
        int st=1;
        int dr=n;
        int res;
        while(st<=dr)
        {
            int mid=(st+dr)/2;
            if(aux[mid]>=x && aux[mid-1]<x)
            {
                res=mid;
                break;
            }
            if(aux[mid]<x)
                st=mid+1;
            else
                dr=mid-1;
        }
        cout<<v[res]/div[res]<<nl;

    }





    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:87:20: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   87 |         cout<<v[res]/div[res]<<nl;
      |                    ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 15 ms 5468 KB Output is correct
4 Correct 19 ms 2652 KB Output is correct
5 Correct 34 ms 7252 KB Output is correct
6 Correct 20 ms 5464 KB Output is correct
7 Correct 35 ms 7248 KB Output is correct
8 Correct 34 ms 7152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 15 ms 5468 KB Output is correct
4 Correct 19 ms 2652 KB Output is correct
5 Correct 34 ms 7252 KB Output is correct
6 Correct 20 ms 5464 KB Output is correct
7 Correct 35 ms 7248 KB Output is correct
8 Correct 34 ms 7152 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 18 ms 3268 KB Output is correct
24 Correct 24 ms 6492 KB Output is correct
25 Correct 51 ms 10436 KB Output is correct
26 Correct 30 ms 6736 KB Output is correct
27 Correct 27 ms 6744 KB Output is correct
28 Correct 50 ms 10832 KB Output is correct
29 Correct 48 ms 10324 KB Output is correct
30 Correct 27 ms 3924 KB Output is correct
31 Correct 50 ms 10832 KB Output is correct