QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#339145#5050. ValueYcfhnndWA 1ms3780kbC++201.5kb2024-02-26 20:04:122024-02-26 20:04:13

Judging History

你现在查看的是最新测评结果

  • [2024-02-26 20:04:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3780kb
  • [2024-02-26 20:04:12]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

void solve(){
    int n;
    cin >> n;
    vector<int>a(n + 1), b(n + 1);
    for (int i = 1;i <= n;i ++){
        cin >> a[i];
    }
    for (int i = 1;i <= n;i ++){
        cin >> b[i];
    }

    vector<vector<int>>adj(n + 1);
    vector<int>vis(n + 1);
    for (int i = 1;i <= n;i ++){
        if (vis[i]) continue;
        i64 j = 1;
        while (j * i <= n){
            j *= i;
            adj[i].push_back(j);
            vis[j] = 1;
            if (i == 1) break;
        }
    }

    i64 ans = 0;
    for (int i = 1;i <= n;i ++){
        if (adj[i].empty()) continue;
        int n = adj[i].size();
        i64 res = 0;
        for (int mask = 1;mask < (1 << n); mask ++){
            i64 score = 0;
            for (int j = 0;j < n;j ++){
                if (mask >> j & 1){
                    score += a[adj[i][j]];
                }
                for (int k = 0;k < j;k ++){
                    if (mask >> j & 1){
                        if ((j + 1) % (k + 1) == 0){
                            score -= b[adj[i][j]];
                        }
                    }
                }
            }
            res = max(res, score);
        }
        ans += res;
    }
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    while (T --){
        solve();
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3776kb

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: 3540kb

input:

4
1 1 1 1
1 1 1 2

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

1
4
10

output:

4

result:

ok 1 number(s): "4"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

2
6 8
2 4

output:

14

result:

ok 1 number(s): "14"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

5
1 6 10 5 1
7 1 5 10 9

output:

18

result:

ok 1 number(s): "18"

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3780kb

input:

10
2 2 8 10 2 10 8 10 6 5
9 2 7 4 2 2 8 3 10 10

output:

50

result:

wrong answer 1st numbers differ - expected: '55', found: '50'