QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#400122 | #6692. Building Company | xunxxxx | WA | 0ms | 3852kb | C++23 | 1.2kb | 2024-04-26 23:51:37 | 2024-04-26 23:51:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int g,a,b,n,m,k,ans;
void solve()
{
map<int,int>h;
map<int,vector<pair<int,int>>>ne,re;
cin>>g;
while(g--)
{
cin>>a>>b;
h[a]+=b;
}
cin>>n;
vector<int>in(n+1);
queue<int>q;
for(int i=1;i<=n;i++)
{
cin>>m;
while(m--)
{
cin>>a>>b;
if(h[a]>=b) continue;
ne[a].push_back({b,i});//ÐèÇó
in[i]++;//¶ÈÊý++
}
cin>>k;
while(k--)
{
cin>>a>>b;
re[i].push_back({a,b});//½±Àø
}
if(in[i]==0) q.push(i);
}
for(auto i:ne) sort(i.second.begin(),i.second.end());
ans=q.size();
while(q.size())
{
int i=q.front();
q.pop();
for(auto j:re[i])
{
a=j.first;
b=j.second;
h[a]+=b;
for(int k=0;k<ne[a].size();k++)
{
if(h[a]>=ne[a][k].first)
{
in[ne[a][k].second]--;
if(in[ne[a][k].second]==0)
{
q.push(in[ne[a][k].second]);
ans++;
}
}
else
{
vector<pair<int,int>>v;
for(int k1=k;k1<ne[a].size();k1++) v.push_back(ne[a][k1]);
ne[a]=v;
break;
}
}
}
}
cout<<ans<<"\n";
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int T=1;
//cin>>T;
while(T--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
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
Wrong Answer
time: 0ms
memory: 3852kb
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:
3
result:
wrong answer 1st numbers differ - expected: '10', found: '3'