# 題目

AP325 Q-4-17. 死線高手

# 解題思路

目前沒東西...

# 程式碼

#include<bits/stdc++.h>
using namespace std;
#define N 100005
struct dead{
    int time,dline;
};
bool cmp(dead a,dead b){
    return a.dline<b.dline;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    bool ans[25]={0};
    cin>>t;
    for(int i=0,n;i<t;i++){
        cin>>n;
        dead d[N];
        for(int j=0;j<n;j++)
            cin>>d[j].time;
        for(int j=0;j<n;j++)
            cin>>d[j].dline;
        sort(d,d+n,cmp);
        bool test=1;
        for(int j=0,now=0;j<n;j++){
            now+=d[j].time;
            if(now>d[j].dline){
                test=0;
                break;
            } 
        }
        if(test) ans[i]=1;
    }
    for(int i=0;i<t;i++)
        if(ans[i]==0)
            cout<<"no\n";
        else
            cout<<"yes\n";
    return 0;
}
更新於 閱讀次數 次