답안 #698402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698402 2023-02-13T11:12:02 Z yeyso Intercastellar (JOI22_ho_t1) C++14
0 / 100
2000 ms 12108 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<vector<int>> pieces(n, vector<int>(0, 0));
    int x;
    int t = 0;
    for(int i = 0; i < n; i ++){
        cin >> x;
        t = 1;
        while(x % 2 == 0){
            x /= 2;
            t *= 2;
        }
        pieces[i] = {x, t};
    }
    //cout << "pieces";
    /*for(int i = 0; i < n; i ++){
        //for(int j = 0; j < pieces[i][1]; j ++){
        cout << pieces[i][0] << " ";
        //}
    }*/
    //cout << "\n";
    vector<int> ps(n, 0);
    ps[0] = pieces[0][1];
    //cout << ps[0] << " ";
    /*for(int i = 1; i < n; i ++){
        ps[i] = ps[i-1] + pieces[i][1];
        cout << ps[i] << " ";
    }*/
    int q; cin >> q;
    int lf = 0;
    for(int i = 0; i < q; i ++){
        cin >> x;
        for(int j = 0; j < n; j ++){
            if(x <= ps[j]){
                //cout << "SIZE: " << pieces[j][0] << "!\n";
                cout << pieces[j][0] << "\n";
                break;
            }
        }
        // binary search for 
    }
}
/*
4
14
9
8
12
15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
*/

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:32:9: warning: unused variable 'lf' [-Wunused-variable]
   32 |     int lf = 0;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Execution timed out 2055 ms 12108 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Execution timed out 2055 ms 12108 KB Time limit exceeded
4 Halted 0 ms 0 KB -