結果
| 問題 | 
                            No.1537 私の代わりに仕事やっといてください。
                             | 
                    
| コンテスト | |
| ユーザー | 
                             umezo
                         | 
                    
| 提出日時 | 2021-06-06 19:12:19 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 146 ms / 2,000 ms | 
| コード長 | 1,031 bytes | 
| コンパイル時間 | 2,356 ms | 
| コンパイル使用メモリ | 203,208 KB | 
| 最終ジャッジ日時 | 2025-01-22 04:13:13 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 9 | 
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long ull;
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<pair<int,int>> A(n);
  rep(i,n){
    int a;
    cin>>a;
    A[i]={a,i+1};
  }
  sort(ALL(A));
  
  vector<int> B;
  if(n%2==0){
    for(int i=0;i<n;i+=2) B.push_back(A[i].second);
    for(int i=n-1;i>0;i-=2) B.push_back(A[i].second);
  }
  else{
    for(int i=0;i<n;i+=2) B.push_back(A[i].second);
    for(int i=n-2;i>0;i-=2) B.push_back(A[i].second);
  }
  
  vector<int> C;
  rep(i,n) C.push_back(B[i]);
  rep(i,n) C.push_back(B[i]);
  
  int b=0;
  vector<int> D;
  rep(i,2*n){
    if(b==0 && C[i]!=1) continue;
    else if(b==0 && C[i]==1){
      b=1;
      D.push_back(C[i]);
    }
    else if(b==1 && C[i]!=1){
      D.push_back(C[i]);
    }
    else if(b==1 && C[i]==1){
      D.push_back(C[i]);
      break;
    }
  }
  rep(i,n+1){
    if(i) cout<<" ";
    cout<<D[i];
  }
  cout<<endl;
  
  return 0;
}
            
            
            
        
            
umezo