結果
問題 |
No.365 ジェンガソート
|
ユーザー |
![]() |
提出日時 | 2017-03-09 22:57:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 774 bytes |
コンパイル時間 | 700 ms |
コンパイル使用メモリ | 73,152 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 00:17:07 |
合計ジャッジ時間 | 2,810 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 |
ソースコード
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> using namespace std; #define ll long long #define PI acos(-1.0) #define FOR(I,A,B) for(int I = (A); I < (B); ++I) //方針 //答え見た //n-(一番大きい数字から見て1ずつ小さくなってる個数) //ex) 13245786 // 8 - 2(78->6が後ろにあるので2つ) int main(){ int N; cin >> N; int a[N]; FOR(i, 0, N) cin >> a[i]; int n = N; int hiku = 0; for(int i=N-1; i>=0; --i){ if(a[i]==n){ hiku++; n--; } } cout << N - hiku << endl; }