QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#576258#8790. First BillionLegend_dy#WA 32ms79352kbC++201.0kb2024-09-19 19:39:302024-09-19 19:39:30

Judging History

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

  • [2024-09-19 19:39:30]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:79352kb
  • [2024-09-19 19:39:30]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

const int N = 1e2 + 5, M = 1e6;
int n, a[N], f[N][M];
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    // cout << a[1] + a[5] + a[6] + a[7] + a[9] << endl;

    for(int i = 1; i <= n; i++) {
        a[i] %= M;
    }

    f[0][0] = -1;
    for(int i = 1; i < n; i++) {
        for(int j = 0; j < M; j++) {
            int k = (j - a[i] + M) % M;
            if(f[i - 1][k] != 0) {
                f[i][j] = i;
            } else if(f[i - 1][j] != 0) {
                f[i][j] = f[i - 1][j];
            }
        }
    }

    vector<int> ans;
    int j = 0;
    for(int i = n - 1; i >= 1; i--) {
        if(f[i][j] == i) {
            ans.push_back(i);
            j = (j - a[i] + M) % M;
        }
    }
    cout << ans.size() << ' ';
    sort(ans.begin(), ans.end());
    for(auto t : ans) {
        cout << t << ' ';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 19ms
memory: 38456kb

input:

10
386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997

output:

5 1 5 6 7 9 

result:

ok OK (n = 10)

Test #2:

score: 0
Accepted
time: 9ms
memory: 40500kb

input:

10
119486233 299942886 169540407 349937991 597883752 32230162 140514533 57341098 12602102 220520836

output:

5 2 5 6 8 9 

result:

ok OK (n = 10)

Test #3:

score: 0
Accepted
time: 26ms
memory: 57124kb

input:

14
384615281 84612238 83310504 54746763 142296081 56775470 128760350 343006424 177232390 214368720 67220468 21895072 16352717 224807522

output:

7 1 6 7 9 10 12 13 

result:

ok OK (n = 14)

Test #4:

score: 0
Accepted
time: 16ms
memory: 52732kb

input:

14
270208635 14270307 89661499 113578022 47687195 101043954 38775146 208193324 650676076 351701957 3427619 59535626 24230888 27009752

output:

7 1 2 3 4 6 10 12 

result:

ok OK (n = 14)

Test #5:

score: -100
Wrong Answer
time: 32ms
memory: 79352kb

input:

20
61638928 106712373 5946815 178135484 4937573 111395400 15504655 67139983 101814514 312223647 130341028 43244171 37671364 54108486 337181317 37924824 153793862 70383750 102917244 66984582

output:

12 1 2 3 4 7 8 9 11 13 17 18 19 

result:

wrong answer need sum 1000000000, got sum  1032000000