結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-04-29 22:33:03 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 29 ms / 2,000 ms | 
| コード長 | 448 bytes | 
| コンパイル時間 | 500 ms | 
| コンパイル使用メモリ | 59,272 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-12 01:39:12 | 
| 合計ジャッジ時間 | 2,189 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 41 | 
ソースコード
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, pos;
  int a[100000];
  int count = 0;
  cin >> n;
  for (int ni = 0; ni < n; ++ni) {
    cin >> a[ni];
  }
  pos = n - 1;
  for (int len = n; len > 0; --len) {
    while (pos >= 0) {
      if (a[pos] == len) {
        --pos;
        break;
      }
      --pos;
      ++count;
    }
  }
  cout << count << endl;
  return 0;
}
            
            
            
        