답안 #674550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674550 2022-12-25T06:10:28 Z guagua0407 Intercastellar (JOI22_ho_t1) C++17
100 / 100
78 ms 8364 KB
/*
希望全國賽不要墊底

全國賽策略:
0:00-0:15:讀題
0:15-3:00:寫掉有把握的
3:00-5:00:撈分+寫掉快好的

記得上廁所
記得吃東西
*/
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end() 
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

int main() {_
    //setIO("wayne");
    int n;
    cin>>n;
    int num[n+1];
    for(int i=1;i<=n;i++){
        cin>>num[i];
    }
    vector<ll> pre(n+1,0);
    for(int i=1;i<=n;i++){
        ll tmp=1;
        while(num[i]%2==0){
            tmp*=2;
            num[i]/=2;
        }
        pre[i]=tmp+pre[i-1];
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        cout<<num[lower_bound(all(pre),x)-pre.begin()]<<'\n';
    }
    return 0;
}
//maybe its multiset not set

Compilation message

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:24:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 21 ms 3284 KB Output is correct
4 Correct 30 ms 2064 KB Output is correct
5 Correct 49 ms 4756 KB Output is correct
6 Correct 29 ms 3364 KB Output is correct
7 Correct 52 ms 4784 KB Output is correct
8 Correct 50 ms 4792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 324 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 1 ms 212 KB Output is correct
10 Correct 1 ms 324 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 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 21 ms 3284 KB Output is correct
4 Correct 30 ms 2064 KB Output is correct
5 Correct 49 ms 4756 KB Output is correct
6 Correct 29 ms 3364 KB Output is correct
7 Correct 52 ms 4784 KB Output is correct
8 Correct 50 ms 4792 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 0 ms 324 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 1 ms 212 KB Output is correct
18 Correct 1 ms 324 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 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 34 ms 2896 KB Output is correct
24 Correct 33 ms 4688 KB Output is correct
25 Correct 63 ms 7916 KB Output is correct
26 Correct 47 ms 4992 KB Output is correct
27 Correct 39 ms 4944 KB Output is correct
28 Correct 75 ms 8360 KB Output is correct
29 Correct 78 ms 7856 KB Output is correct
30 Correct 39 ms 3540 KB Output is correct
31 Correct 74 ms 8364 KB Output is correct