QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#252308 | #6692. Building Company | Teal | RE | 0ms | 9068kb | C++14 | 1.7kb | 2023-11-15 18:01:04 | 2023-11-15 18:01:05 |
Judging History
answer
#include <set>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define N (100010)
#define inf (0x3f3f3f3f)
#define INF (0x3f3f3f3f3f3f3f3fll)
#define LL long long
#define PII pair<int, int>
#define fir first
#define sec second
int g, n, M[N], ans;
unordered_map<int, LL> tot;
vector<PII> Bonus[N];
priority_queue<PII, vector<PII>, greater<PII>> Req[N];
queue<int> q;
PII P[N];
inline int read() {
int x = 0, f = 1; char ch = getchar();
while (ch < '0' || ch > '9')
ch == '-' ? f = -1, ch = getchar() : ch = getchar();
while (ch >= '0' && ch <= '9')
x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return x * f;
}
void solve(PII& now) {
tot[now.fir] += now.sec;
int val = tot[now.fir], type = now.fir;
while(!Req[type].empty()) {
int x = Req[type].top().fir;
int id = Req[type].top().sec;
// printf("%d %d %d\n", type, x, id);
if (val < x) break;
Req[type].pop();
if (--M[id] == 0) q.push(id);
}
}
int main() {
// ios::sync_with_stdio(false);
g = read();
int tmp;
for (int i = 1; i <= g; ++i)
P[i].fir = read(), P[i].sec = read();
n = read();
for (int i = 1; i <= n; ++i) {
M[i] = tmp = read();
if (!tmp) q.push(i);
int a, b;
for (int j = 1; j <= tmp; ++j) {
a = read(), b = read();
Req[a].push(PII(b, i));
}
tmp = read();
for (int j = 1; j <= tmp; ++j) {
a = read(), b = read();
Bonus[i].push_back(PII(a, b));
}
}
for (int i = 1; i <= g; ++i) solve(P[i]);
while (!q.empty()) {
++ans;
int id = q.front(); q.pop();
// printf("%d\n", id);
for (int i = 0; i < Bonus[id].size(); ++i) solve(Bonus[id][i]);
}
printf("%d\n", ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 9068kb
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...