結果

問題 No.2055 12x34...
ユーザー charmychachacha
提出日時 2022-08-29 22:03:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 345 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 201,540 KB
最終ジャッジ日時 2025-02-06 23:37:49
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; int A[200010];
	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i];
	map<int, long long> mp;
	long long ans = -N;
	for(int i = 0; i < N; i++){
		ans += mp[A[i] - 1] + 1;
		mp[A[i]] += mp[A[i] - 1] + 1;
	}
	cout << ans << "\n";
}
0