-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathb.cpp
45 lines (42 loc) · 765 Bytes
/
b.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <bits/stdc++.h>
#define endl '\n'
#define eat cin
#define moo cout
#define int long long
using namespace std;
int T, N, K, S[100000], A[100000];
int32_t main(){
eat.tie(0) -> sync_with_stdio(0);
eat >> T;
while(T--){
eat >> N >> K;
bool ok = 1;
int pv = 0, pvd = -1e15;
int fd = 0;
fill(A, A+N+1, 0);
for(int i = 0; i < K; i++){
eat >> S[i];
if(i != 0){
int cd = S[i] - S[i-1];
A[i+N-K] = cd;
}
}
for(int i = N-K; i >= 0; i--){
A[i] = A[i+1];
}
int s = accumulate(A, A+N-K+1, 0LL);
if(s < S[0]){
ok = 0;
}
for(int i = 1; i < N; i++){
if(A[i] < A[i-1]){
ok = 0;
}
}
/*for(int i = 0; i < N; i++){
moo << A[i] << ' ';
}*/
if(K == 1) ok = 1;
moo << (ok ? "Yes" : "No") << endl;
}
}