直接对时间进行枚举,本以为会超时,没想到过了,过了就过了、、
#include<bits/stdc++.h> using namespace std; set<int>keep[10105]; set<int>back[10105]; int a[1005]; int main(){ int N,K; scanf("%d%d",&N,&K); for(int i=1;i<=N;i++){ a[i]=i; } int w,s,c; int mx=0; for(int i=0;i<K;i++){ scanf("%d%d%d",&w,&s,&c); mx=max(mx,s+c); keep[s].emplace(w); back[s+c].emplace(w); } for(int i=1;i<=mx;i++){ if(!back[i].empty()){ for(set<int>::iterator it=back[i].begin();it!=back[i].end();it++){ for(int i=1;i<=N;i++){ if(a[i]==0){ a[i]=(*it); break; } } } } if(!keep[i].empty()){ for(set<int>::iterator it=keep[i].begin();it!=keep[i].end();it++){ for(int i=1;i<=N;i++){ if(a[i]==*it){ a[i]=0; break; } } } } } for(int i=1;i<=N;i++){ printf("%d ",a[i]); } }
标签:begin,iterator,int,csp201709,back,10105 From: https://www.cnblogs.com/yds0823/p/17185394.html