結果

問題 No.1687 What the Heck?
ユーザー pengin_2000pengin_2000
提出日時 2022-09-12 17:09:50
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 28,684 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 20:53:45
合計ジャッジ時間 2,625 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 0 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 12 ms
4,376 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 25 ms
4,376 KB
testcase_13 AC 25 ms
4,380 KB
testcase_14 AC 25 ms
4,376 KB
testcase_15 AC 24 ms
4,376 KB
testcase_16 AC 25 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 25 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int p[200005];
int q[200005];
int main()
{
	long long int n;
	scanf("%lld", &n);
	int i;
	for (i = 0; i < n; i++)
		scanf("%d", &p[i]);
	for (i = 0; i < n; i++)
		q[p[i]] = i + 1;
	long long int ans = 0, v = n * (n + 1) / 2;
	for (i = n; i > 1; i--)
	{
		v -= 2 * q[i];
		if (ans < v)
			ans = v;
		v += q[i];
	}
	printf("%lld\n", ans);
	return 0;
}
0