UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#207336#3737. 环形排列Allen123456hello10068ms1912kbC++11519b2024-07-28 17:52:372024-07-28 20:02:16

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,arr[200005];
LL ans=0,mas=INT_MAX;
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;++i){scanf("%d",arr+i);mas=min(mas,(LL)arr[i]);}
    ans+=mas*(LL)(n);for (int i=1;i<=n;++i){arr[i]-=mas;}
    for (int i=1;i<=n;++i){arr[n+i]=arr[i];}
    n<<=1;
    int pre=1,len=0;
    for (int i=1;i<=n;++i){
        if (arr[i]){len=max(len,i-pre+1);}
        else{pre=i+1;}
    }
    ans+=len;
    printf("%lld",ans);
    return 0;
}

详细

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

Test #1:

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

input:

89
7 73 94 66 44 75 5 9 70 72 44 76 9 33 60 8 69 90 90 84 3 36 18 36 93 50 93 35 6 42 13 84 77 87 54...

output:

177

result:

ok 1 number(s): "177"

Test #2:

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

input:

60
99 66 88 61 46 65 63 67 78 9 18 32 3 68 78 95 14 60 10 61 21 31 37 30 17 2 52 15 64 25 22 17 42 9...

output:

179

result:

ok 1 number(s): "179"

Test #3:

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

input:

87
13 6 77 80 61 29 8 39 86 45 34 74 3 80 93 1 58 64 55 44 97 45 40 10 17 2 41 63 48 16 97 72 41 58 ...

output:

173

result:

ok 1 number(s): "173"

Test #4:

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

input:

96
5 50 58 24 34 95 90 15 27 93 34 83 90 7 14 74 7 40 10 1 26 71 84 1 39 90 20 27 69 39 10 46 15 92 ...

output:

161

result:

ok 1 number(s): "161"

Test #5:

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

input:

97
60 53 46 3 46 63 48 42 4 88 36 20 17 43 94 72 54 32 58 94 75 60 64 43 58 85 27 9 18 15 3 56 94 13...

output:

360

result:

ok 1 number(s): "360"

Test #6:

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

input:

62966
330210506 23366392 159887830 705497471 124004178 706684817 910724424 775263417 664925120 87753...

output:

2640542175

result:

ok 1 number(s): "2640542175"

Test #7:

score: 10
Accepted
time: 7ms
memory: 1676kb

input:

61957
118820899 829730035 23314447 633396086 377662488 919984944 919003467 339788701 945146767 65105...

output:

16232733

result:

ok 1 number(s): "16232733"

Test #8:

score: 10
Accepted
time: 18ms
memory: 1796kb

input:

77780
66297113 976157271 19647930 774611076 277641407 953536944 946078293 694845875 267232535 636308...

output:

676919339

result:

ok 1 number(s): "676919339"

Test #9:

score: 10
Accepted
time: 15ms
memory: 1672kb

input:

61091
422807084 174475787 892583983 666833469 717466783 814919988 856718118 687447394 493896456 3296...

output:

1203003971

result:

ok 1 number(s): "1203003971"

Test #10:

score: 10
Accepted
time: 22ms
memory: 1912kb

input:

91889
903946660 463419474 19623104 263194043 848046074 604050091 808139856 635900953 717793180 62412...

output:

99056341

result:

ok 1 number(s): "99056341"