QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#283321#5693. 众数YeahPotato#AC ✓10ms4492kbC++14424b2023-12-14 14:25:472023-12-14 14:25:47

Judging History

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

  • [2023-12-14 14:25:47]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:4492kb
  • [2023-12-14 14:25:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N], p[N], mx; long long s, ans;
int main() {
	cin >> n;
	for (int i=1; i<=n; i++)
		scanf ("%d", &a[i]), p[i] = i, s += a[i];
	sort (p+1, p+n+1, [] (const int &i, const int &j) { return a[i] < a[j]; });
	for (int i=n; i; s-=a[p[i--]])
		if (p[i] > mx)
			ans += (s + 1ll * (n - i) * a[p[i]]) * (p[i] - mx), mx = p[i];
	cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 4492kb

input:

99991
3 3 3 4 3 6 4 2 2 5 3 2 3 5 3 3 2 1 2 3 4 2 3 4 3 3 3 4 3 3 3 2 3 2 3 2 4 3 3 2 3 5 3 5 4 2 4 3 3 1 3 2 2 3 4 2 3 3 2 2 4 5 3 2 3 3 1 3 3 4 1 3 4 5 1 1 3 4 2 4 3 2 5 3 3 2 2 2 4 2 4 2 2 4 2 4 3 3 2 3 2 2 1 4 3 1 3 1 2 2 3 1 1 5 2 1 2 2 3 3 1 4 4 4 3 3 3 3 1 3 3 5 5 4 4 3 3 3 4 3 6 5 3 1 1 2 2 ...

output:

4973056284288

result:

ok single line: '4973056284288'

Test #2:

score: 0
Accepted
time: 6ms
memory: 4380kb

input:

69992
90001 89998 90001 90001 89997 90000 90000 90002 90003 90003 90001 89999 89999 90000 90000 90000 90000 90000 90000 90001 90000 89999 90002 90001 90000 89998 89998 90001 89998 90000 90000 89999 90000 90001 89998 90000 90004 90000 90000 90001 89999 90001 90003 89998 90001 90001 90001 90001 90002 ...

output:

465680822171522

result:

ok single line: '465680822171522'

Test #3:

score: 0
Accepted
time: 3ms
memory: 4360kb

input:

79992
999 1001 1000 999 997 1002 1003 1000 1002 1001 1004 1000 1000 1002 1001 1000 1002 1000 999 998 1001 998 1000 1001 1000 1001 999 1001 1000 1001 1001 1001 1000 1000 1001 1001 1002 999 1002 1000 997 999 1002 1000 999 999 999 997 1003 1002 999 1000 998 997 999 1000 1001 999 1000 1003 999 999 1001 ...

output:

2099568054432

result:

ok single line: '2099568054432'

Test #4:

score: 0
Accepted
time: 7ms
memory: 4236kb

input:

79995
99997 99999 100000 99999 99999 100000 99999 99998 99997 99999 100000 99999 99998 100000 99999 99999 100000 99999 99996 99995 99996 99996 99994 99993 99994 99995 99993 99996 99996 99995 99998 99995 99993 99993 99997 99995 99995 99996 99995 99996 99994 99994 99996 99995 99995 99997 99997 99996 9...

output:

597436378953787

result:

ok single line: '597436378953787'

Test #5:

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

input:

2
97077 93226

output:

376755

result:

ok single line: '376755'

Test #6:

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

input:

100
90081 90225 90250 90271 90341 90362 90387 90414 90455 90500 90589 90641 90687 90691 90715 90722 90731 90866 90900 91180 91224 91256 91387 91558 91617 91632 91665 91717 92360 92806 92820 92845 92852 92853 93021 93042 93068 93156 93212 93274 93444 93537 93604 93711 93733 93836 93909 94015 94068 94...

output:

946924500

result:

ok single line: '946924500'

Test #7:

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

input:

100
99460 98233 94497 92874 91707 91443 89387 88877 88744 87085 85679 84707 83527 82943 82121 82107 78982 78879 78241 77720 77080 76481 76068 74980 74611 74487 74450 73100 72302 72214 70826 70766 70027 69790 69384 68887 67198 66447 66029 65739 65592 64467 63711 63397 61683 59072 56810 53435 52849 52...

output:

366000017

result:

ok single line: '366000017'

Test #8:

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

input:

993
34 51 64 15 55 16 55 35 18 62 51 10 37 27 50 44 64 15 1 63 53 57 66 45 61 11 18 50 66 61 43 37 55 30 41 58 63 40 55 16 37 58 51 49 62 55 35 44 64 34 58 43 41 58 31 36 12 51 34 32 46 48 32 53 12 66 63 43 51 27 43 38 2 58 56 31 40 46 57 66 55 44 35 19 39 47 30 37 39 39 64 40 29 32 57 37 50 44 34 2...

output:

40454319

result:

ok single line: '40454319'

Test #9:

score: 0
Accepted
time: 5ms
memory: 4200kb

input:

60000
99999 99999 99997 99996 99996 99994 99992 99992 99988 99988 99984 99984 99983 99981 99981 99977 99977 99978 99973 99968 99965 99968 99961 99961 99961 99958 99955 99958 99956 99956 99952 99949 99952 99950 99949 99945 99944 99942 99941 99936 99937 99935 99931 99930 99930 99929 99923 99924 99922 ...

output:

119997898349058

result:

ok single line: '119997898349058'

Test #10:

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

input:

79997
11240 37280 50257 19453 44653 14897 20693 50513 5106 5099 51113 5776 69819 80837 28194 84967 53473 41380 1679 45336 6472 3140 19052 4487 83421 13168 28065 35279 94192 88836 81411 20279 48551 21414 57848 8548 77649 94678 66626 6751 1874 25359 41865 30659 37719 77881 32078 54038 38744 85200 2403...

output:

320997616259355

result:

ok single line: '320997616259355'

Test #11:

score: 0
Accepted
time: 8ms
memory: 4456kb

input:

99997
99999 99994 99998 99998 100000 99999 99995 100000 99998 100000 99997 99999 100000 100000 99998 99997 99999 99999 99996 99994 99999 99998 99997 99999 99997 100000 5665 99998 99997 99998 99996 99998 99997 99996 99998 99998 99998 99996 99998 99999 99999 99997 99998 99997 99997 99997 100000 99997 ...

output:

966704175674031

result:

ok single line: '966704175674031'

Test #12:

score: 0
Accepted
time: 5ms
memory: 4048kb

input:

49993
9115 52815 19655 4538 26673 2905 2904 30346 24500 88467 91035 2905 30342 91033 5376 19419 19656 2903 83887 91034 83890 42873 83890 42870 24502 19421 58528 9111 26675 35984 35983 9115 30346 58891 19420 88467 35982 2903 24500 35981 19660 35982 78775 4537 19420 58893 4541 24500 91034 4538 19422 2...

output:

100071885757841

result:

ok single line: '100071885757841'

Test #13:

score: 0
Accepted
time: 8ms
memory: 4384kb

input:

99991
93540 93537 93540 93540 93539 93540 93541 93538 93540 93538 93541 93539 93541 93537 93540 93540 93540 93540 93540 93540 93538 93541 93540 93540 93537 93540 93541 93540 93542 93540 93537 93542 93541 93541 93540 93540 93538 93539 93540 93538 93540 93537 93542 93539 93544 93541 93544 93540 93542 ...

output:

272602857817651

result:

ok single line: '272602857817651'