Submission #68323342
Source Code Expand
#include <string>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
constexpr int MOD = 1000000007;
vector<lint> RH_B = {1532834020, 1388622299};
vector<lint> RH_M = {2147482409, 2147478017};
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int N, Q;
cin >> N >> Q;
vector<lint> A(N);
REP(i, N) {
cin >> A[i];
}
sort(ALL(A));
int Amax = A[N-1];
vector<lint> B(1000000, -1);
B[0] = 1;
int rest = N;
int ptr = 0;
FOR(i, 1, 1000000) {
while(ptr < N && A[ptr] < i) {
rest--;
ptr++;
}
B[i] = B[i - 1] + rest;
}
REP(i, Q) {
int x;
cin >> x;
if(x > Amax) {
cout << -1 << "\n";
continue;
}
x--;
cout << B[x] << "\n";
}
}
Submission Info
Submission Time |
|
Task |
C - Flush |
User |
Shun_PI |
Language |
C++ 20 (gcc 12.2) |
Score |
350 |
Code Size |
1434 Byte |
Status |
AC |
Exec Time |
100 ms |
Memory |
14464 KiB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
350 / 350 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00-sample-01.txt, 00-sample-02.txt |
All |
00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt |
Case Name |
Status |
Exec Time |
Memory |
00-sample-01.txt |
AC |
5 ms |
10964 KiB |
00-sample-02.txt |
AC |
5 ms |
10944 KiB |
01-01.txt |
AC |
11 ms |
10960 KiB |
01-02.txt |
AC |
9 ms |
11124 KiB |
01-03.txt |
AC |
12 ms |
11060 KiB |
01-04.txt |
AC |
100 ms |
14336 KiB |
01-05.txt |
AC |
61 ms |
13324 KiB |
01-06.txt |
AC |
89 ms |
14356 KiB |
01-07.txt |
AC |
73 ms |
14464 KiB |
01-08.txt |
AC |
72 ms |
14336 KiB |
01-09.txt |
AC |
96 ms |
14076 KiB |