QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#693479#6692. Building Companyustcwaitme#TL 0ms3612kbC++231.2kb2024-10-31 16:15:022024-10-31 16:15:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 16:15:08]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3612kb
  • [2024-10-31 16:15:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
typedef pair<int,int> PII;
const int N=1e5+10;

int g,n;
struct sb{
	vector<int> a,b;
};

void solve(){
	int res=0;
	map<int,int> num;
	map<int,priority_queue<PII,vector<PII>,greater<PII>>> st;
	cin>>g;
	for(int i=1;i<=g;i++){
		int t,u;cin>>t>>u;
		num[t]+=u;
	}
	cin>>n;
	vector<sb> add(n+10);
	vector<int> op(n+10,0);
	auto upd=[&](auto&& upd,int x)->void{
		++res;
		for(int i=0;i<add[x].a.size();i++){
			int a=add[x].a[i],b=add[x].b[i];
			int& val=num[a];
			val+=b;
			priority_queue<PII,vector<PII>,greater<PII>>& q=st[a];
			while(q.size()&&q.top().first<=val){
				int pos=q.top().second;
				if(--op[pos]==0){
					upd(upd,pos);
				}
				q.pop();
			} 
		}
	};
	for(int i=1;i<=n;i++){
		int m;cin>>m;op[i]=m;
		for(int j=1;j<=m;j++){
			int a,b;cin>>a>>b;
			if(num[a]>=b) --op[i];
			else st[a].push({b,i});
		}
		int k;cin>>k;
		add[i].a.resize(k);
		add[i].b.resize(k);
		for(int j=1;j<=k;j++){
			int c,d;cin>>c>>d;
			add[i].a[j-1]=c;
			add[i].b[j-1]=d;
		}
		if(op[i]==0){
			upd(upd,i);
		}
	}
	cout<<res<<endl;
}


signed main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

2 2 1 1 2
5
1 3 1
0
2 1 1 2 1
2 3 2 2 1
3 1 5 2 3 3 4
1 2 5
3 2 1 1 1 3 4
1 1 3
0
1 3 2

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: -100
Time Limit Exceeded

input:

3 610031727 590328742 816793299 18485566 654221125 47823436
10
3 610031727 224714165 816793299 491951703 654221125 593479446
1 610031727 538596643
1 610031727 551036304
3 816793299 262985484 610031727 52580932 654221125 424397787
1 654221125 889197190
3 654221125 126924193 610031727 963399336 816793...

output:


result: