結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-24 21:32:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 529 bytes |
| コンパイル時間 | 1,416 ms |
| コンパイル使用メモリ | 167,728 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 10:08:08 |
| 合計ジャッジ時間 | 2,667 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 10 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;
typedef long long ll;
int main() {
int N;
cin >> N;
vector<int> P(N);
rep(i, 0, N) cin >> P[i];
if (N == 1) {
cout << 0 << endl;
return 0;
}
if (N == 2) {
if (P[0] == 1) cout << 0 << endl;
else cout << 1 << endl;
return 0;
}
ll ans = 0;
rep(i, 0, N) {
if (P[i] == N) ans -= i + 1;
else ans += i + 1;
}
cout << ans << endl;
}