QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#168566 | #5050. Value | absinthe# | WA | 2ms | 3828kb | C++20 | 1.3kb | 2023-09-08 17:27:03 | 2023-09-08 17:27:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) cin >> b[i];
vector<vector<int>> ls(n + 1);
vector<int> done(n + 1);
for (int i = 1; i <= n; i++) {
if (done[i])continue;
int j = 1;
while (j * i <= n) {
j *= i;
ls[i].push_back(j - 1);
done[j]=1;
if (i == 1) break;
}
}
long long ans = 0;
for (int cur = 1; cur <= n; cur++) {
if (ls[cur].empty()) continue;
int n = ls[cur].size();
long long best = 0;
for (int mask = 1; mask < (1 << n); mask++) {
long long score = 0;
for (int i = 0; i < n; i++) {
if ((mask >> i) & 1) {
score += a[ls[cur][i]];
}
for (int j = 0; j < i; j++) {
if ((mask >> j) & 1) {
if ((i + 1) % (j + 1) == 0) {
score -= b[ls[cur][i]];
}
}
}
}
// cout <<cur<<' '<< mask <<' '<<score<<'\n';
best = max(best, score);
}
ans += best;
}
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3528kb
input:
4 1 1 1 2 1 1 1 1
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
4 1 1 1 1 1 1 1 2
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3824kb
input:
1 4 10
output:
4
result:
ok 1 number(s): "4"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 6 8 2 4
output:
14
result:
ok 1 number(s): "14"
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 3572kb
input:
5 1 6 10 5 1 7 1 5 10 9
output:
17
result:
wrong answer 1st numbers differ - expected: '18', found: '17'