比赛 期末考试2 评测结果 AAAAAAATTT
题目名称 物流 最终得分 70
用户昵称 杨蕙宇 运行时间 9.814 s
代码语言 C++ 内存使用 4.74 MiB
提交时间 2026-02-10 11:37:57
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int n,m,s[N],c[N];

bool cmp(int x,int y){
    return x>y;
}
bool work(int a,int b){
    for(int i=1;i<=n;i++)c[i]=s[i];
    sort(c+1,c+1+n,cmp);
    int cnt=0;
    while(c[a]){
        int tmp=c[a];
        cnt+=tmp;
        if(cnt>=b){
            return true;
        }
        for(int i=1;i<=a;i++){
            c[i]-=tmp;
        }
        sort(c+1,c+1+n,cmp);
    }
    return false;
}
int main(){
    freopen("logistics.in","r",stdin);
    freopen("logistics.out","w",stdout);
    cin>>n>>m;
    while(m--){
        char op;
        int a,b;
        cin>>op>>a>>b;
        if(op=='U'){
            s[a]=b;
        }
        else{
            if(work(a,b)){
                cout<<"TAK\n";
            }
            else cout<<"NIE\n";
        }
    } 
    return 0;
}