結果

問題 No.1619 Coccinellidae
ユーザー 👑 NachiaNachia
提出日時 2021-07-22 21:57:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 802 ms
コンパイル使用メモリ 80,408 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-24 16:48:28
合計ジャッジ時間 2,607 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 10 ms
4,376 KB
testcase_02 AC 12 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 12 ms
4,384 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 8 ms
4,380 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 10 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 12 ms
4,384 KB
testcase_14 AC 13 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main(){
  ll N,M,K; cin >> N >> M >> K;
  deque<ll> A(N);
  rep(i,N) A[i] = i;
  A[N-1] += M - (N*(N-1)/2);
  deque<ll> ans;
  while(K != 0){
    if(ans.size() <= K){
      K -= ans.size();
      ans.push_front(A.front());
      A.pop_front();
    }
    else{
      ans.push_back(A.front());
      A.pop_front();
      int p = ans.size()-1;
      while(K != 0){
        K--;
        swap(ans[p-1],ans[p]);
        p--;
      }
    }
  }
  while(A.size()){
    ans.push_back(A.front());
    A.pop_front();
  }
  rep(i,N) cout << ans[i] << "\n";
  return 0;
}

0