Submission #698405

# Submission time Handle Problem Language Result Execution time Memory
698405 2023-02-13T11:22:22 Z yeyso Intercastellar (JOI22_ho_t1) C++14
35 / 100
2000 ms 15068 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n; cin >> n;
    vector<vector<long long>> pieces(n, vector<long long>(0, 0));
    long long x;
    long long t = 0;
    for(long long 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<long long> 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] << " ";
    }
    long long q; cin >> q;
    long long lf = 0;
    vector<long long> res;
    for(long long i = 0; i < q; i ++){
        cin >> x;
        for(long long j = 0; j < n; j ++){
            if(x <= ps[j]){
                //cout << "SIZE: " << pieces[j][0] << "!\n";
                //cout << "s: " << pieces[j][0] << "\n";
                res.push_back(pieces[j][0]);
                break;
            }
        }
        // binary search for 
    }
    for(long long i = 0; i < res.size(); i ++){
        cout << res[i] << "\n";
    }
}
/*
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:47:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(long long i = 0; i < res.size(); i ++){
      |                          ~~^~~~~~~~~~~~
Main.cpp:33:15: warning: unused variable 'lf' [-Wunused-variable]
   33 |     long long lf = 0;
      |               ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1365 ms 12956 KB Output is correct
4 Correct 1324 ms 6436 KB Output is correct
5 Execution timed out 2066 ms 15068 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 316 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1365 ms 12956 KB Output is correct
4 Correct 1324 ms 6436 KB Output is correct
5 Execution timed out 2066 ms 15068 KB Time limit exceeded
6 Halted 0 ms 0 KB -