比赛 期末考试2 评测结果 AAAAAAATTT
题目名称 物流 最终得分 70
用户昵称 zcx 运行时间 9.595 s
代码语言 C++ 内存使用 4.83 MiB
提交时间 2026-02-10 10:17:58
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int const N=1e6+2;
int a[N],b[N];
bool cmp(int x,int y){
    return x>y;
}
int main()
{
    freopen("logistics.in","r",stdin);
    freopen("logistics.out","w",stdout);
    int n,m;
    cin>>n>>m;
    while(m--){
        char op;
        int c,s;
        cin>>op;scanf("%d%d",&c,&s);
        if(op=='U') a[c]=s;
        else{
            for(int i=1;i<=n;i++) b[i]=a[i];
            sort(b+1,b+1+n,cmp);
            int cnt=0,st=1,fi=n;
            while(fi>=st){
                int sum=b[st];
                while(sum<s&&fi>st) sum+=b[fi],fi--;
                if(sum>=s) cnt++;
                st++;
            }
            if(cnt>=c) cout<<"TAK"<<endl;
            else cout<<"NIE"<<endl;
        }
    }
    return 0;
}