QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#417315 | #6692. Building Company | XiaoretaW | WA | 0ms | 3812kb | C++20 | 2.4kb | 2024-05-22 17:18:33 | 2024-05-22 17:18:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r-1; i >= l; --i)
typedef long long ll;
typedef pair<int, int> PI;
template<typename T> bool setmax(T &a, T b) { return (a < b ? a = b, 1 : 0); }
template<typename T> bool setmin(T &a, T b) { return (a > b ? a = b, 1 : 0); }
#define print(a) cerr << "[ "; for (auto it : a) cerr << it << ", "; cerr << "]\n";
int main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int g; cin >> g;
map<int, int> has;
for (int i = 0; i < g; i++) {
int t, u; cin >> t >> u;
has[t] = u;
}
int n; cin >> n;
map<int, int> need;
map<int, multiset<PI>> todo;
vector<vector<PI>> bonus(n);
for (int i = 0; i < n; i++) {
int m; cin >> m;
for (int j = 0; j < m; j++) {
int a, b; cin >> a >> b;
if (has[a] >= b) continue;
++need[i];
todo[a].insert(mp(b, i));
}
int k; cin >> k;
for (int j = 0; j < k; j++) {
int c, d; cin >> c >> d;
bonus[i].push_back(mp(c, d));
}
if (!need[i]) {
// finish
auto get = [&](auto get, int x) -> void {
vector<int> finish;
for (auto [c, d] : bonus[x]) {
has[c] += d;
int cnt = 0;
for (auto [more, id] : todo[c]) {
if (more > has[c]) break;
++cnt;
--need[id];
if (!need[id]) {
// get(get, id);
finish.push_back(id);
}
}
while (cnt--) todo[c].erase(todo[c].begin());
// cerr << "??? " << x << ' ';
// print(finish);
}
assert(sz(finish) == sz(set<int>(all(finish))));
for (int id : finish) get(get, id);
};
get(get, i);
}
}
int ans = 0;
for (int i = 0; i < n; i++) ans += !need[i];
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
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: 3528kb
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:
8
result:
wrong answer 1st numbers differ - expected: '10', found: '8'