結果

問題 No.1687 What the Heck?
ユーザー publflpublfl
提出日時 2021-09-24 21:37:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 45,880 KB
実行使用メモリ 4,608 KB
最終ジャッジ日時 2023-09-18 20:53:19
合計ジャッジ時間 1,677 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 15 ms
4,376 KB
testcase_08 AC 21 ms
4,380 KB
testcase_09 AC 15 ms
4,384 KB
testcase_10 AC 10 ms
4,380 KB
testcase_11 AC 11 ms
4,376 KB
testcase_12 AC 43 ms
4,536 KB
testcase_13 AC 44 ms
4,608 KB
testcase_14 AC 44 ms
4,592 KB
testcase_15 AC 43 ms
4,536 KB
testcase_16 AC 42 ms
4,464 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 43 ms
4,596 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <algorithm>

std::pair<int,int> x[200010];
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&x[i].first);
	for(int i=1;i<=a;i++) x[i].second = i;
	long long int sum = 0;
	for(int i=1;i<=a;i++) sum += i;
	
	std::sort(x+1,x+a+1);
	
	long long int ans = 0;
	for(int i=a;i>=1;i--)
	{
		long long int t = sum - 2*x[i].second;
		ans = ans>t?ans:t;
		sum -= x[i].second;
	}
	printf("%lld",ans);
}
0