QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#168598 | #5050. Value | absinthe# | WA | 1ms | 3488kb | C++20 | 1.4kb | 2023-09-08 17:41:35 | 2023-09-08 17:41:37 |
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;
long long 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]];
}
int ok = 0;
for (int j = 0; j < i; j++) {
if ((mask >> j) & 1) {
if ((i + 1) % (j + 1) == 0) {
score -= b[ls[cur][i]];
ok=1;
}
}
}
}
// 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: 0ms
memory: 3376kb
input:
4 1 1 1 2 1 1 1 1
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3488kb
input:
4 1 1 1 1 1 1 1 2
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3416kb
input:
1 4 10
output:
4
result:
ok 1 number(s): "4"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3404kb
input:
2 6 8 2 4
output:
14
result:
ok 1 number(s): "14"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3456kb
input:
5 1 6 10 5 1 7 1 5 10 9
output:
17
result:
wrong answer 1st numbers differ - expected: '18', found: '17'