結果
問題 |
No.365 ジェンガソート
|
ユーザー |
|
提出日時 | 2022-03-23 10:21:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 988 bytes |
コンパイル時間 | 774 ms |
コンパイル使用メモリ | 92,260 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 07:52:37 |
合計ジャッジ時間 | 2,289 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 |
ソースコード
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <set> #include <queue> #include <stack> #include <cstdio> #include <cstring> #include <cmath> #include <bitset> #include <climits> #define REP(i,n) for (int i=0;i<(n);i++) #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--) #define ll long long #define ull unsigned long long int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; const int INF = 1e9; const ll LL_INF = 1e18; const int MOD = 1e9 + 7; using namespace std; int a[1000001]; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int nowNum = N; int ans = 0; REP(i,N) { cin >> a[i]; } RREP(j,N) { if (a[j] == nowNum) { nowNum--; } else { ans++; } } cout << ans << endl; return 0; }