QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#418739#6691. OrderschenxiiTL 1ms3844kbC++14829b2024-05-23 15:27:532024-05-23 15:27:54

Judging History

你现在查看的是最新测评结果

  • [2024-05-23 15:27:54]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3844kb
  • [2024-05-23 15:27:53]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int N=1e3+10;


void solve(){ 
int n,k;cin>>n>>k;
map<int,int>ac;

int date=0;
for(int i=1;i<=n;i++){
    int a,b;cin>>a>>b;ac[a]+=b;
    date=max(a,date);
}

int cnt=0;bool flag=0;
for(int i=1;i<=date;i++){
    cnt+=k;
    if(ac[i]>cnt){flag=1;cout<<"NO"<<endl;return;}
    else cnt-=ac[i];
}        
            
        
    

   /*
    while(ac[i].day==i){
        //cout<<i<<endl<<endl;
        if(cnt<ac[i].goods){flag=1;}
        else {cnt-=ac[i].goods;}i++;
        }
*/ 


if(flag){cout<<"NO"<<endl;}
else cout<<"YES"<<endl;




}




int main(void){
    IOS
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3844kb

input:

2
4 5
6 12
1 3
6 15
8 1
3 100
3 200
4 300
6 100

output:

YES
NO

result:

ok 2 token(s): yes count is 1, no count is 1

Test #2:

score: -100
Time Limit Exceeded

input:

100
22 5902
2156 41112
4784 2494327
2156 18332
1932 561243
7775 6411977
4325 42582
3982 5455884
7775 3752795
1932 268336
2156 43482
4325 1574341
4325 407463
2156 3547
2156 120919
8417 3789084
4784 214691
1932 4577101
7775 7488110
3982 2029754
1932 5995988
3982 3291414
2156 1094658
69 8933
6042 13932...

output:

NO
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
NO
NO
NO
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
NO
NO
YES
NO
YES
YES
YES
NO
YES
...

result: