QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#789999 | #6692. Building Company | Nlll# | WA | 0ms | 3556kb | C++17 | 1.9kb | 2024-11-27 23:29:07 | 2024-11-27 23:29:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
ll a, b;
node(ll a = 0, ll b = 0) : a(a), b(b) {}
bool operator < (const node &x) const {
return b > x.b;
}
};
unordered_map<ll, ll> mp;
unordered_map<ll, priority_queue<node>> qa;
struct bonus{
int n;
vector<ll> a, b;
bonus(int n = 0) : n(n) {
a.resize(n + 1);
b.resize(n + 1);
}
void read()
{
cin >> n;
a.resize(n + 1);
b.resize(n + 1);
for(int i = 1; i <= n; i++)
{
cin >> a[i] >> b[i];
}
}
};
void solve()
{
int n, m;
cin >> m;
queue<pair<ll, ll>> q;
for(int i = 1; i <= m; i++)
{
ll x, y;
cin >> x >> y;
q.push({x, y});
}
cin >> n;
int ans = 0;
vector<int> d(n + 1);
vector<bonus> B(n + 1);
for(int i = 1; i <= n; i++)
{
cin >> d[i];
for(int j = 1; j <= d[i]; j++)
{
ll x, y;
cin >> x >> y;
qa[x].push({i, y});
}
B[i].read();
if(d[i] == 0)
{
ans++;
for(int j = 1; j <= B[i].n; i++)
{
q.push({B[i].a[j], B[i].b[j]});
}
}
}
while(!q.empty())
{
auto [x, y] = q.front();
q.pop();
mp[x] += y;
while(!qa[x].empty() && qa[x].top().b <= mp[x])
{
auto [a, b] = qa[x].top();
qa[x].pop();
d[a]--;
if(!d[a])
{
ans++;
for(int i = 1; i <= B[a].n; i++)
{
q.push({B[a].a[i], B[a].b[i]});
}
}
}
}
cout << ans << "\n";
}
int main()
{
cin.tie(0)->sync_with_stdio(false);
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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: 3556kb
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:
2
result:
wrong answer 1st numbers differ - expected: '10', found: '2'