QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#699203 | #6769. Monster Hunter | beamishboys# | WA | 1ms | 3800kb | C++23 | 1.3kb | 2024-11-02 05:21:14 | 2024-11-02 05:21:14 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
void solve() {
int n; cin >> n;
vector<ll> a(n);
for (ll &i : a) cin >> i;
int m; cin >> m;
vector<ll> h(m);
for (ll &i : h) cin >> i;
ll lb = 1, ub = 1e17;
ll oneTot = 0, twoTot = 0, threeTot = 0;
for (int i = 0; i < a.size(); i++) {
if (a[i] == 1) oneTot += 1;
if (a[i] == 2) twoTot += 1;
if (a[i] == 3) threeTot += 1;
}
while (lb < ub-1) {
ll m = (lb+ub)/2;
ll cycle = m / a.size();
ll one = cycle*oneTot, two = cycle*twoTot, three = cycle*threeTot;
for (int i = 0; i < m%a.size(); i++) {
if (a[i] == 1) one += 1;
if (a[i] == 2) two += 1;
if (a[i] == 3) three += 1;
}
bool bad = false;
for (ll x : h) {
ll useThree = min(three, x / 3);
three -= useThree;
x -= useThree * 3;
ll useTwo = min(two, x / 2);
two -= useTwo;
x -= useTwo * 2;
ll useOne = min(one, x);
one -= useOne;
x -= useOne;
if (x == 1 && two > 0) {
two--;
x = 0;
}
if (x >= 1 && three > 0) {
three--;
x = 0;
}
if (x > 0) bad = true;
}
if (!bad) ub = m;
else lb = m;
}
cout << lb+1 << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t; cin >> t;
while (t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
input:
2 2 3 2 3 2 4 2 5 1 2 3 2 1 2 3 3
output:
4 3
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3596kb
input:
100 21 1 3 3 3 2 3 3 2 2 1 3 2 1 3 2 1 1 1 3 3 3 3 3 3 1 19 1 3 1 1 3 3 1 3 2 3 2 2 3 3 1 1 2 2 2 10 2 2 3 1 5 2 2 5 5 3 8 1 3 3 1 3 2 3 1 3 1 2 1 27 1 1 1 2 1 3 1 2 2 3 3 3 1 1 1 1 2 1 2 2 2 2 3 2 1 3 2 4 5 1 2 2 23 2 1 3 2 3 2 2 3 1 2 1 3 1 2 3 1 3 1 2 2 2 1 1 10 4 3 5 4 5 4 1 4 3 4 8 1 2 1 3 2 3 ...
output:
3 15 3 7 19 12 3 8 7 20 5 10 6 10 3 10 16 2 5 6 10 14 13 8 8 5 13 15 5 10 16 14 10 2 11 4 4 16 5 4 7 8 7 5 13 11 10 11 15 3 10 8 19 16 8 25 11 21 2 3 14 12 4 12 17 22 11 3 14 15 2 9 12 7 3 9 4 9 11 2 2 5 6 3 2 2 4 6 7 10 3 14 2 2 5 4 9 13 14 16
result:
wrong answer 18th lines differ - expected: '1', found: '2'