QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#693446 | #6692. Building Company | ustcwaitme# | TL | 0ms | 3564kb | C++23 | 1.2kb | 2024-10-31 16:10:24 | 2024-10-31 16:10:26 |
Judging History
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;//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];
num[a]+=b;
while(st[a].size()&&st[a].top().first<=num[a]){
int pos=st[a].top().second;
if(--op[pos]==0){
upd(upd,pos);
}
st[a].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;
for(int j=1;j<=k;j++){
int c,d;cin>>c>>d;
add[i].a.push_back(c);
add[i].b.push_back(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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
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...