結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  ふーらくたる | 
| 提出日時 | 2016-07-06 11:22:28 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 11 ms / 2,000 ms | 
| コード長 | 547 bytes | 
| コンパイル時間 | 392 ms | 
| コンパイル使用メモリ | 57,528 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-12 20:25:49 | 
| 合計ジャッジ時間 | 1,728 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 41 | 
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
const int kMAX_N = 100010;
int N;
int a[kMAX_N];
void Solve() {
    reverse(a, a + N);
    int ans = 0, s = 0, num = N;
    while (s < N) {
        int t = s;
        while (t < N && a[t] != num) {
            ans++;
            t++;
        }
        num--;
        s = t + 1;
    }
    cout << ans << endl;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    Solve();
    return 0;
}
            
            
            
        