QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#399781 | #6692. Building Company | MCdyc | WA | 114ms | 19108kb | C++20 | 2.0kb | 2024-04-26 17:46:55 | 2024-04-26 17:46:55 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
#define pii pair<i64, i64>
#define mp make_pair
using namespace std;
using i64 = unsigned long long;
void solve()
{
int g;
cin >> g;
map<i64, i64> staff;
for (int i = 1; i <= g; i++)
{
i64 t, u;
cin >> t >> u;
staff[t] = u;
}
int n;
cin >> n;
map<i64, i64> qry;
map<i64, set<pii>> need, gain;
map<i64, priority_queue<pii, vector<pii>, greater<pii>>> q;
for (int i = 1; i <= n; i++)
{
int m;
cin >> m;
while (m--)
{
i64 a, b;
cin >> a >> b;
need[i].insert(mp(a, b));
q[a].emplace(b, i);
}
int k;
cin >> k;
while (k--)
{
i64 c, d;
cin >> c >> d;
gain[i].insert(mp(c, d));
}
}
vector<bool> vis(n+1);
queue<int> que;
for (int i = 1; i <= n; i++)
{
for (auto [a, b] : need[i])
{
if (staff[a] >= b)
qry[i]++;
}
if (qry[i] == need[i].size())
que.push(i);
}
// cout << "OK input\n";
// while(que.size()){
// cout<<que.front()<<endl;
// que.pop();
// }
int ans = 0;
while (que.size())
{
ans++;
int u = que.front();
que.pop();
if(vis[u])
continue;
vis[u]=true;
for (auto [c, d] : gain[u])
{
staff[c] += d;
while (q[c].size() && staff[c] >= q[c].top().first)
{
auto [a, b] = q[c].top();
q[c].pop();
qry[b]++;
if (qry[b] == need[b].size())
que.push(b);
}
}
}
cout << ans;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3852kb
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: 0ms
memory: 3656kb
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: 0
Accepted
time: 1ms
memory: 3888kb
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:
100
result:
ok 1 number(s): "100"
Test #4:
score: 0
Accepted
time: 3ms
memory: 3996kb
input:
33 598906111 952747266 214206082 308472115 773699301 71970369 334282917 266176016 861160505 745480638 397625705 130382274 75028923 106125916 739923352 754152044 493886549 212094717 352869179 727757279 697376464 343501623 916521518 80952344 90959088 722016125 286878647 329186592 770901193 30277256 92...
output:
100
result:
ok 1 number(s): "100"
Test #5:
score: -100
Wrong Answer
time: 114ms
memory: 19108kb
input:
380 562284409 583959039 705240193 694592025 91058796 151967354 775570098 571811699 457579493 117213529 684664737 33837962 60865228 186423701 316573783 868301583 744570505 934432338 790259030 364551324 145817136 961903964 737096543 759008968 865899868 681823261 273067044 247683791 186025557 756452454...
output:
1000
result:
wrong answer 1st numbers differ - expected: '992', found: '1000'