QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#379390 | #6692. Building Company | asaltfish | WA | 0ms | 3628kb | C++20 | 1.4kb | 2024-04-06 17:23:36 | 2024-04-06 17:23:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read() {
register int s = 0, w = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
s = s * 10 + ch - '0', ch = getchar();
return s * w;
}
struct node
{
int x, y;
bool operator < (const node& a) const //重载
{
return x > a.x; //x小的优先级高
}
};
//priority_queue<node>s;
map<ll, ll>s,h;
map<ll, priority_queue<node>>d;
map<ll, map<ll, ll>>f;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n, m, p, sh;
m = read();
for (int i = 1; i <= m; i++)
{
p = read(), sh = read();
h[p] = sh;
}
n = read();
for (int u = 1; u <= n; u++)
{
m = read();
for (int i = 1; i <= m; i++)
{
p = read(), sh = read();
node op = { sh,u };
d[p].push(op);
}
m = read();
s[u] = m;
for (int i = 1; i <= m; i++)
{
p = read(), sh = read();
f[u][p] = sh;
}
}
ll g = 0, k = 0;
while (1)
{
g = 0;
for (auto i : h)
{
ll op = i.first;
while (!d[op].empty() && d[op].top().x <= h[op])
{
s[d[op].top().y]--;
if (s[d[op].top().y] == 0)
{
k++;
g++;
for (auto y : f[d[op].top().y])
{
h[d[op].top().y] += f[d[op].top().y][d[op].top().x];
}
}
d[op].pop();
}
}
if (g == 0 || k == n)break;
}
cout << k+2;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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: 3628kb
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'