QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#953368#6692. Building CompanyfengjiugeWA 1ms3712kbC++231.3kb2025-03-27 19:06:312025-03-27 19:06:32

Judging History

This is the latest submission verdict.

  • [2025-03-27 19:06:32]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3712kb
  • [2025-03-27 19:06:31]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long

struct p{
	int fa;
	int val;
};

struct cmp{
	bool operator ()(const p &a,const p& b){
		return a.val>b.val;
	}
};

map<int,priority_queue<p,vector<p>,cmp>> pq={};
map<int,int> mp={};
map<int,int> tmpmp={};
map<int,map<int,int>> addvec={};
map<int,int> nowmp={};
map<int,int> nedmp={};
map<int,int> flg={};

signed main()
{
	int g;cin>>g;
	int tt,uu;
	for(int i=0;i<g;i++){
		cin>>tt>>uu;
		mp[tt]=uu;
	}
	int n;cin>>n;
	for(int i=0;i<n;i++){
		int m;cin>>m;
		if(m==0){
			flg[i]=1;
		}
		for(int j=0;j<m;j++){
			int a,b;cin>>a>>b;
			pq[a].push({i,b});
			nedmp[i]++;
		}
	}
	for(int i=0;i<n;i++){
		int k;cin>>k;
		for(int j=0;j<k;j++){
			int c,d;cin>>c>>d;
			if(flg[i]){
				mp[c]+=d;
			}
			else{
				addvec[i][c]=d;
			}
		}
	}
	int ans=0;
	while(mp.size()){
		for(auto i:mp){
			int typ=i.first;
			nowmp[typ]+=mp[typ];
			while(!pq[typ].empty()){
				p topp=pq[typ].top();
				pq[typ].pop();
				if(topp.val<=nowmp[typ]){
					nedmp[topp.fa]--;
					if(nedmp[topp.fa]==0){
						ans++;
						for(auto j:addvec[topp.fa]){
							tmpmp[j.first]+=j.second;
						}
					}
				}
				else{
					pq[typ].push(topp);
					break;
				}
			}
		}
		mp=tmpmp;
		tmpmp={};
	}
	cout<<ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3584kb

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: 0
Accepted
time: 1ms
memory: 3584kb

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:

10

result:

ok 1 number(s): "10"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3712kb

input:

10 720543365 814021419 777649737 273919247 339754140 472967790 545693058 298289557 949226024 176807538 267294560 819212220 337794335 504610276 137418995 614590802 632556957 783062334 587607535 115519693
100
5 949226024 327424834 777649737 117746775 137418995 152960310 720543365 423301366 267294560 4...

output:

95

result:

wrong answer 1st numbers differ - expected: '100', found: '95'