QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#932606 | #6692. Building Company | huo_hua_ya | RE | 1ms | 5732kb | C++23 | 1.8kb | 2025-03-12 19:55:44 | 2025-03-12 19:55:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 7;
const int mod9 = 998244353;
const int mod1 = 1e9 + 7;
#define int ll
map<int, priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>>> mp; // 这种工人, 所有需要这个项目该工种人数的小根堆
int ne[N];
vector<pair<int, int>> kk[N];
map<int, int> has;
int n, g;
queue<int> q;
int ans = 0;
void doo()
{
while (q.size())
{
auto i = q.front();
q.pop();
ans++;
for (int j = 0; j < (int)kk[i].size(); j++)
{
auto [c, d] = kk[i][j];
has[c] += d;
while (mp[c].size() && mp[c].top().first <= has[c])
{
auto [a, b] = mp[c].top();
mp[c].pop();
ne[a]--;
if (ne[a] == 0)
q.push(b);
}
}
}
}
void solve()
{
cin >> g;
for (int i = 1; i <= g; i++)
{
int t, h;
cin >> t >> h;
has[t] = h;
}
cin >> n;
for (int i = 1; i <= n; i++)
{
int m;
cin >> m;
ne[i] = m;
for (int j = 1; j <= m; j++)
{
int a, b;
cin >> a >> b;
if (has[a] >= b)
ne[i]--;
else
mp[a].push({b, i});
}
if (ne[i] == 0)
q.push(i);
int k;
cin >> k;
for (int j = 1; j <= k; j++)
{
int c, d;
cin >> c >> d;
kk[i].push_back({c, d});
}
}
doo();
cout << ans << '\n';
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
// cin >> _;
while (_--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5732kb
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...