| 比赛 |
期末考试2 |
评测结果 |
AAAAAAATTT |
| 题目名称 |
物流 |
最终得分 |
70 |
| 用户昵称 |
PXCZM |
运行时间 |
8.110 s |
| 代码语言 |
C++ |
内存使用 |
16.69 MiB |
| 提交时间 |
2026-02-10 09:47:40 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int n,m;
int a[1000010];
multiset<int>st;
priority_queue<int,vector<int>,greater<int> >q;
int main()
{
freopen("logistics.in","r",stdin);
freopen("logistics.out","w",stdout);
cin>>n>>m;
for(int i=1;i<=n;i++) st.insert(0);
while(m--)
{
char op;
int x,y;
cin>>op>>x>>y;
if(op=='U')
{
auto it=st.lower_bound(a[x]);
st.erase(it);
a[x]=y;
st.insert(y);
}
else
{
while(q.size()) q.pop();
for(int i=1;i<=x;i++) q.push(y);
for(auto it=st.rbegin();it!=st.rend()&&q.size();it++)
{
int tmp=*it,top=q.top();
if(!tmp) break;
q.pop();
if(top>tmp) q.push(top-tmp);
}
if(q.empty()) cout<<"TAK\n";
else cout<<"NIE\n";
}
}
return 0;
}