Submission #68378737
Source Code Expand
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> ti;
typedef vector<bool> vb;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OS;
//FOR BLITZ READING INPUT/OUTPUT TEXT FILES
//ifstream fin("input.txt");
//ofstream fout("output.txt");
void solve() {
int n, q;
cin >> n >> q;
vll vals(n);
rep(i, 0, n) cin >> vals[i];
sort(all(vals));
vll res(1000001, -1);
int lidx = 0;
ll num = n;
ll cur = 1 - n;
for (int i = 1; i <= vals[n - 1]; i++) {
while (vals[lidx] < i - 1) lidx++, num--;
cur += num;
res[i] = cur;
}
for (int i = 0; i < q; i++) {
int v;
cin >> v;
cout << res[v] << endl;
}
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int test = 1;
//cin >> test;
for (int t = 0; t < test; t++) {
solve();
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Flush |
| User | rensdebot73 |
| Language | C++ 20 (gcc 12.2) |
| Score | 350 |
| Code Size | 1352 Byte |
| Status | AC |
| Exec Time | 367 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 | 11036 KiB |
| 00-sample-02.txt | AC | 5 ms | 10948 KiB |
| 01-01.txt | AC | 47 ms | 10920 KiB |
| 01-02.txt | AC | 44 ms | 10900 KiB |
| 01-03.txt | AC | 49 ms | 10936 KiB |
| 01-04.txt | AC | 367 ms | 14380 KiB |
| 01-05.txt | AC | 340 ms | 13364 KiB |
| 01-06.txt | AC | 352 ms | 14340 KiB |
| 01-07.txt | AC | 337 ms | 14464 KiB |
| 01-08.txt | AC | 342 ms | 14332 KiB |
| 01-09.txt | AC | 359 ms | 14088 KiB |