結果

問題 No.1687 What the Heck?
ユーザー rabimea
提出日時 2023-02-15 18:59:57
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 386 bytes
コンパイル時間 2,438 ms
コンパイル使用メモリ 221,564 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 17:31:07
合計ジャッジ時間 4,557 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

int readInt() {
	int x;
	readf!" %d"(x);
	return x;
}
int[] readArray(int n) {
	auto a = new int[](n);
	return a.map!(i => readInt).array;
}


void main() {
	int n = readInt;
	int[] p = readArray(n);
	
	long ans = 0;
	auto q = zip(n.iota.array, p);
	
	foreach(i; 0 .. n) {
		int sgn = (p[i] == n ? -1 : 1);
		ans += sgn * (i + 1);
	}
	if(n == 1) ans = 0;
	writeln(ans);
}

0