QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#699431#6692. Building CompanyAaRE 0ms9292kbC++171.2kb2024-11-02 08:58:022024-11-02 08:58:02

Judging History

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

  • [2024-11-02 08:58:02]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:9292kb
  • [2024-11-02 08:58:02]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#define int long long
using namespace std;
typedef pair<int,int> PII;
int now[100010];
int cnt[100010];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int n,m;
	cin >> n;
	for(int i=1;i<=n;i++){
		int x,c;
		cin >> x >> c;
		now[x]=c;
	}
	vector<PII> gain[100010];
	priority_queue<PII,vector<PII>,greater<PII>> heap;
	priority_queue<PII,vector<PII>,greater<PII>> pre[100010];
	cin >> m; 
	for(int i=1;i<=m;i++){
		int k;
		cin >> k;
		while(k--){
			int x,c;
			cin >> x >> c;
			if(now[x]<c){
				cnt[i]++;
				pre[x].push({c,i});
			}
		}
		heap.push({cnt[i],i});
		cin >> k;
		while(k--){
			int x,c;
			cin >> x >> c;
			gain[i].push_back({x,c});
		}
	}
	int res=0;
	while(heap.size() && heap.top().first==0){
		int t=heap.top().second;
		heap.pop();
		res++;
		map<int,bool> S;
		for(PII x:gain[t]){
			now[x.first]+=x.second;
			while(pre[x.first].size() && pre[x.first].top().first<=now[x.first]){
				cnt[pre[x.first].top().second]--;
				S[pre[x.first].top().second]=true;
				pre[x.first].pop();
			}
		}
		for(PII x:S){
			heap.push({cnt[x.first],x.first});
		}
	}
	cout << res;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Runtime Error

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: