Submission #68338121
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, Q;cin >> N >> Q;
long long A[N], pfx[N+1];
for (int i=0;i<N;i++) cin >> A[i];
pfx[0] = 0;
sort(A, A+N);
for (int i=1;i<=N;i++) pfx[i] = pfx[i-1] + A[i-1];
for (int i=0;i<Q;i++) {
int B;cin >> B;
if (B>A[N-1]) {
cout << -1 << endl;
continue;
}
int MN=lower_bound(A, A+N, B)-A;
//printf("DX : %d\n", MN);
cout << pfx[MN]+(N-MN)*(B-1)+1 << endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Flush |
| User | re_d2023zyh |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 478 Byte |
| Status | WA |
| Exec Time | 496 ms |
| Memory | 8740 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | 1 ms | 3500 KiB |
| 00-sample-02.txt | AC | 1 ms | 3480 KiB |
| 01-01.txt | AC | 47 ms | 3604 KiB |
| 01-02.txt | AC | 47 ms | 3448 KiB |
| 01-03.txt | AC | 48 ms | 3524 KiB |
| 01-04.txt | WA | 496 ms | 8728 KiB |
| 01-05.txt | WA | 405 ms | 8088 KiB |
| 01-06.txt | WA | 421 ms | 8596 KiB |
| 01-07.txt | WA | 432 ms | 8716 KiB |
| 01-08.txt | WA | 427 ms | 8740 KiB |
| 01-09.txt | WA | 488 ms | 8108 KiB |