QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#421802 | #6769. Monster Hunter | ohiostatescarlet | WA | 1ms | 3636kb | C++17 | 2.0kb | 2024-05-26 05:36:56 | 2024-05-26 05:36:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define L long long
void push(L&src, L&dst, L&amt, int cost=1) {
L mv = min(src, amt / cost);
src -= mv;
amt -= mv * cost;
dst += mv;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int t; cin >> t;
for (int ti = 0; ti < t; ti++) {
int n;
cin >> n;
vector<vector<L>> occ(3,vector<L>(n+1,0));
for (int i = 0; i < n; i++) {
int v;
cin >> v;
occ[v-1][i+1]++;
for (int j = 0; j < 3; j++) occ[j][i+1] += occ[j][i];
}
int mc;
cin >> mc;
vector<L> cost(7,0);
L tot = 0;
L targ = 0;
for (int i = 0; i < mc; i++) {
L v;
cin >> v;
tot += v;
if (v > 6) {
cost[6] += v / 6;
targ += v / 6;
v %= 6;
}
if (v) {
targ++;
cost[v]++;
}
}
L l = 1, h = 1e14;
while (l < h) {
L m = (l + h) / 2;
if (m >= tot) {
h = m;
continue;
}
L mul = m / n;
L off = m % n;
L t1 = occ[0][n] * mul + occ[0][off];
L t2 = occ[1][n] * mul + occ[1][off];
L t3 = occ[2][n] * mul + occ[2][off];
vector<L> curr = cost;
push(curr[5],curr[2],t3);
push(curr[3],curr[0],t3);
push(curr[6],curr[0],t3,2);
push(curr[4],curr[1],t3);
push(curr[2],curr[0],t3);
push(curr[1],curr[0],t3);
push(curr[6],curr[3],t3);
push(curr[6],curr[4],t2);
push(curr[5],curr[3],t2);
push(curr[4],curr[2],t2);
push(curr[3],curr[1],t2);
push(curr[2],curr[0],t2);
push(curr[1],curr[0],t2);
push(curr[6],curr[5],t1);
push(curr[5],curr[4],t1);
push(curr[4],curr[3],t1);
push(curr[3],curr[2],t1);
push(curr[2],curr[1],t1);
push(curr[1],curr[0],t1);
if (curr[0] == targ) {
h = m;
} else {
l = m + 1;
}
}
cout << l << "\n";
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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: 0
Accepted
time: 1ms
memory: 3620kb
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 1 5 6 10 14 13 8 8 5 13 15 5 10 16 14 10 1 10 4 3 16 5 4 7 8 7 5 13 10 10 10 14 3 9 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 5 3 2 2 4 6 7 10 3 14 2 1 5 4 8 13 14 16
result:
ok 100 lines
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3636kb
input:
100 22 3 3 3 1 3 2 3 3 3 3 2 2 3 3 1 2 1 2 3 2 3 1 3 10 1 8 11 1 3 2 1 3 3 1 1 1 1 1 3 3 5 13 21 3 1 2 3 2 1 2 1 3 2 2 1 1 1 1 3 2 3 2 3 2 4 1 5 7 10 8 2 1 3 3 2 2 2 2 3 8 11 8 4 2 1 1 2 2 12 8 26 1 2 3 3 1 2 2 2 2 1 3 1 3 2 1 2 1 3 2 1 1 3 2 3 3 2 4 8 6 5 13 30 1 1 3 2 2 1 2 3 1 3 3 2 3 2 2 3 1 2 3...
output:
8 13 12 13 13 18 11 7 6 23 5 5 12 20 2 22 9 10 3 4 23 12 10 5 9 5 11 17 1 20 9 26 8 13 14 11 13 9 17 5 7 11 17 18 18 16 5 19 8 2 13 20 9 8 19 14 16 12 21 19 9 24 7 16 8 5 5 21 1 4 9 9 10 15 7 11 10 2 6 3 4 18 26 8 9 8 12 3 8 6 9 7 20 2 10 22 16 20 14 13
result:
wrong answer 6th lines differ - expected: '17', found: '18'