UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#194387#3414. 等差数列liborui100127ms1196kbC++454b2023-10-15 11:30:142023-10-15 12:32:56

answer

#include <bits/stdc++.h>

#define int long long 

using namespace std;

signed main()
{
    int n;
    cin >> n;
    int sum = 0;
    
    for (int i = 1; i <= n; i ++ )
    {
        int a;
        cin >> a;
        sum += a;
    }
    
    if (n % 2 == 1) cout << min(abs(sum % n), abs(sum % n - n));
    else cout << min(min(abs(sum % n), abs(sum % n - n)), min(abs(sum % n - n / 2), abs(sum % n + n / 2)));
    
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1192kb

input:

10
5 4 2 3 3 1 1 2 1 1

output:

2

result:

ok single line: '2'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1196kb

input:

9
5 0 4 2 3 4 1 1 2

output:

4

result:

ok single line: '4'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1192kb

input:

8
1 0 1 5 2 1 1 3

output:

2

result:

ok single line: '2'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1196kb

input:

9010
10 13 9 5 1 16 11 10 9 0 1 15 7 12 0 2 8 20 13 16 19 9 18 16 3 15 2 19 3 7 2 19 17 18 3 14 16 2...

output:

1336

result:

ok single line: '1336'

Test #5:

score: 10
Accepted
time: 0ms
memory: 1196kb

input:

511
18 14 19 9 4 19 17 9 14 17 16 17 16 5 20 20 1 13 0 9 4 10 13 16 7 11 4 3 20 19 6 14 18 1 8 17 12...

output:

58

result:

ok single line: '58'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1192kb

input:

1000
14 18 20 14 17 17 12 15 7 5 20 18 14 15 2 13 18 14 16 7 11 6 18 16 3 3 3 16 16 1 12 12 11 16 3 ...

output:

125

result:

ok single line: '125'

Test #7:

score: 10
Accepted
time: 39ms
memory: 1196kb

input:

100000
487226969 457282779 405894670 507533594 752274125 691586010 899032024 977434663 549675232 670...

output:

21795

result:

ok single line: '21795'

Test #8:

score: 10
Accepted
time: 40ms
memory: 1192kb

input:

99999
910117004 226112810 689456274 981491037 882117040 962190328 363339027 851861175 830129398 6518...

output:

13785

result:

ok single line: '13785'

Test #9:

score: 10
Accepted
time: 42ms
memory: 1192kb

input:

99824
806648101 561706280 619418755 463645466 392810359 655120318 721691580 866225896 49402289 57677...

output:

15593

result:

ok single line: '15593'

Test #10:

score: 10
Accepted
time: 6ms
memory: 1192kb

input:

14234
57476255 821933964 604566231 906210451 472885299 646948133 912526078 895605300 382635721 55351...

output:

3209

result:

ok single line: '3209'

Extra Test:

score: 0
Extra Test Passed