답안 #644051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644051 2022-09-23T16:07:14 Z ToroTN Intercastellar (JOI22_ho_t1) C++14
100 / 100
94 ms 9280 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define X first
#define Y second
ll n,a,t,x,num,pos=1,pow_2[35];
vector<pair<ll,ll> > v;
int main()
{
    pow_2[0]=1;
    for(int i=1;i<=30;i++)
    {
        pow_2[i]=pow_2[i-1]*2;
    }
    v.pb({-1,-1});
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a);
        num=0;
        while(a%2==0)
        {
            a/=2;
            ++num;
        }
        v.pb({a,pow_2[num]});
    }
    for(int i=2;i<=n;i++)
    {
        v[i].Y=v[i-1].Y+v[i].Y;
    }
    scanf("%lld",&t);
    while(t--)
    {
        scanf("%lld",&a);
        while(a>v[pos].Y)++pos;
        printf("%lld\n",v[pos].X);
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
Main.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%lld",&a);
      |         ~~~~~^~~~~~~~~~~
Main.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%lld",&t);
      |     ~~~~~^~~~~~~~~~~
Main.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%lld",&a);
      |         ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 27 ms 5032 KB Output is correct
4 Correct 37 ms 2372 KB Output is correct
5 Correct 81 ms 5556 KB Output is correct
6 Correct 36 ms 5012 KB Output is correct
7 Correct 62 ms 5604 KB Output is correct
8 Correct 61 ms 5748 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 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 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 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 27 ms 5032 KB Output is correct
4 Correct 37 ms 2372 KB Output is correct
5 Correct 81 ms 5556 KB Output is correct
6 Correct 36 ms 5012 KB Output is correct
7 Correct 62 ms 5604 KB Output is correct
8 Correct 61 ms 5748 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 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 34 ms 3100 KB Output is correct
24 Correct 60 ms 6048 KB Output is correct
25 Correct 77 ms 8824 KB Output is correct
26 Correct 53 ms 5692 KB Output is correct
27 Correct 47 ms 6048 KB Output is correct
28 Correct 94 ms 9280 KB Output is correct
29 Correct 88 ms 8812 KB Output is correct
30 Correct 47 ms 3804 KB Output is correct
31 Correct 93 ms 9148 KB Output is correct