結果

問題 No.2740 Old Maid
ユーザー YNotchi_HKTIte2
提出日時 2024-04-21 10:44:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 656 bytes
コンパイル時間 1,590 ms
コンパイル使用メモリ 170,184 KB
実行使用メモリ 15,104 KB
最終ジャッジ日時 2024-10-13 09:35:28
合計ジャッジ時間 9,381 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  vector<int> vec2(0);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 1; i <= N; i++) {
    auto it = find(vec.begin(), vec.end(), i);
    if( it != vec.end() ) {
      int index = distance(vec.begin(), it);
      if (index == vec.size() - 1){
      }else{
        vec2.push_back(vec.at(index));
        vec2.push_back(vec.at(index + 1));
        vec.erase(vec.begin() + index);
        vec.erase(vec.begin() + index);
        i++;
      }
    }
  }
  
  for (int i = 0; i < N; i++) {
    cout << vec2[i] << ' ';
  }
}
0