結果
問題 |
No.365 ジェンガソート
|
ユーザー |
![]() |
提出日時 | 2020-09-29 21:13:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 525 bytes |
コンパイル時間 | 1,698 ms |
コンパイル使用メモリ | 172,612 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 12:14:20 |
合計ジャッジ時間 | 3,919 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define INF 1000000000000000000 using ll=long long; using Graph=vector<vector<int>>; int main(){ int N; cin>>N; vector<pair<int,int>> A(N); for(int i=0;i<N;i++){ cin>>A[i].first; } vector<pair<int,int>> B(N); for(int i=0;i<N;i++){ B[i]=make_pair(A[i].first,i); } sort(B.begin(),B.end()); for(int i=0;i<N;i++){ A[B[i].second].second=i; } int k=N-1; for(int i=N-1;i>=0;i--){ if(A[i].second==k){ k--; } } cout<<k+1<<endl; }