问题描述
问题分析
刚开始想一年一年模拟
结果超时了
于是想了想
简化了一些没必要的循环
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
| #include<stdio.h>
#include<algorithm>
using namespace std;
int main() {
int Q,N,K,T;
int i,j,p;
int a[12000];
scanf("%d",&Q);
while(Q--) {
scanf("%d %d %d",&N,&K,&T);
for(i=0; i<N; i++) {
scanf("%d",&a[i]);
a[i]-=T;
}
for(j=p=0; p<T&&j<N; j++) {
while(a[j]>0&&p<T) {
a[j]-=K-1;
p++;
}
}
for(i=0; i<N; i++) {
if(a[i]>0)
break;
}
if(i<N)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
|
题目地址:【郑轻】[1803]SC晾衣服