結果

問題 No.365 ジェンガソート
ユーザー Fujisaki_prprFujisaki_prpr
提出日時 2016-04-29 23:47:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,707 ms / 2,000 ms
コード長 1,986 bytes
コンパイル時間 1,130 ms
コンパイル使用メモリ 161,544 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 06:11:14
合計ジャッジ時間 13,979 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 633 ms
6,944 KB
testcase_17 AC 785 ms
6,940 KB
testcase_18 AC 8 ms
6,944 KB
testcase_19 AC 577 ms
6,944 KB
testcase_20 AC 39 ms
6,944 KB
testcase_21 AC 54 ms
6,944 KB
testcase_22 AC 597 ms
6,940 KB
testcase_23 AC 205 ms
6,944 KB
testcase_24 AC 549 ms
6,940 KB
testcase_25 AC 51 ms
6,940 KB
testcase_26 AC 320 ms
6,940 KB
testcase_27 AC 1,014 ms
6,940 KB
testcase_28 AC 370 ms
6,940 KB
testcase_29 AC 839 ms
6,940 KB
testcase_30 AC 384 ms
6,940 KB
testcase_31 AC 80 ms
6,940 KB
testcase_32 AC 69 ms
6,940 KB
testcase_33 AC 983 ms
6,940 KB
testcase_34 AC 31 ms
6,944 KB
testcase_35 AC 544 ms
6,940 KB
testcase_36 AC 390 ms
6,940 KB
testcase_37 AC 1,707 ms
6,944 KB
testcase_38 AC 1,042 ms
6,944 KB
testcase_39 AC 199 ms
6,944 KB
testcase_40 AC 289 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(all(v),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,ans = 0;
  cin >> N;
  vary(int,v,N,0);
  rep(i,N){
    cin >> v[i];
  }
  int a = 1;
  int num = 0;
  while(a <= N){
    num = 0;
    if(a == N) break;
    for(auto it = v.begin(); it != v.end();){
      if(*it == a){
        it = v.erase(it);
        ++num;
        ++a;
      }
      else ++it;
    }
    ans += num;
  }
  cout << ans -num<< endl;
  return 0;
}
0