QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#837829#9920. Money Game 2propaneWA 1ms3588kbC++201.5kb2024-12-30 14:40:142024-12-30 14:40:24

Judging History

This is the latest submission verdict.

  • [2024-12-31 22:17:02]
  • hack成功,自动添加数据
  • (/hack/1322)
  • [2024-12-31 21:57:13]
  • hack成功,自动添加数据
  • (/hack/1321)
  • [2024-12-30 14:40:24]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3588kb
  • [2024-12-30 14:40:14]
  • Submitted

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<array>
#include<algorithm>
using namespace std;
using LL = long long;

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    const int M = 33;
    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        vector<int> a(n);
        int cnt = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            if (a[i] != 1) cnt += 1;
        }
        vector<array<LL, M + 1> > l(n), r(n);
        for(int i = 0; i < n; i++){
            l[i][0] = a[i];
            for(int j = 1; j <= M and j < n; j++){
                l[i][j] = l[i][j - 1] / 2 + a[(i - j + n) % n];
            }
            r[i][0] = a[i];
            for(int j = 1; j <= M and j < n; j++){
                r[i][j] = r[i][j - 1] / 2 + a[(i + j) % n];
            }
        }
        for(int i = 0; i < n; i++){
            LL ans = a[i];
            for(int j = 0; j <= M and j < n; j++){
                for(int k = 0; k <= M and j + k < n; k++){
                    ans = max(ans, r[(i - j + n) % n][j] + l[(i + k) % n][k] - a[i]);
                }
            }
            if (cnt - (a[i] > 1) >= 2){
                ans = max(ans, a[i] + 2LL);
            }
            if (cnt - (a[i] > 1) >= 1){
                ans = max(ans, a[i] + 1LL);
            }
            cout << ans << " \n"[i + 1 == n];
        }
    }

}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3460kb

input:

3
5
2 1 4 3 5
5
2 1 3 1 2
1
1000000000

output:

6 5 7 8 8
4 4 5 4 4
1000000000

result:

ok 11 numbers

Test #2:

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

input:

1
10
8 15 18 15 13 4 14 4 17 5

output:

30 37 41 39 34 27 29 26 31 27

result:

ok 10 numbers

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3588kb

input:

1000
4
8 9 7 9
1
9
1
10
2
3 9
3
4 3 2
4
0 4 3 1
4
10 8 4 6
1
9
1
4
4
10 10 1 6
1
9
1
0
2
4 6
4
8 1 6 7
2
5 10
4
9 2 1 4
3
5 5 9
3
9 8 9
4
4 8 5 6
2
10 1
1
7
3
9 2 4
4
2 4 1 2
3
5 2 1
1
4
3
2 0 9
4
7 3 10 1
3
4 1 2
2
6 4
1
2
3
3 1 5
3
5 8 4
2
9 3
4
5 9 10 3
4
6 5 4 0
1
6
4
3 1 10 1
4
1 9 5 7
4
8 1 6 ...

output:

18 18 17 18
9
10
7 10
6 6 5
3 6 5 3
18 16 13 15
9
4
18 17 11 14
9
1
7 8
13 9 11 14
10 12
12 7 6 9
11 11 13
17 16 17
12 14 13 12
10 6
7
12 8 9
5 6 4 4
6 4 4
4
6 5 11
11 11 13 10
5 4 4
8 7
2
5 4 6
11 12 10
10 7
13 17 16 12
9 10 8 6
6
6 7 11 7
9 13 12 11
14 10 12 16
18 15 18 19
5
11 13
4 4 6 8
12 14 13...

result:

wrong answer 13th numbers differ - expected: '5', found: '6'