結果

問題 No.1619 Coccinellidae
ユーザー monnumonnu
提出日時 2021-07-23 19:25:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 4,817 ms
コンパイル使用メモリ 225,960 KB
実行使用メモリ 4,800 KB
最終ジャッジ日時 2023-09-25 18:26:38
合計ジャッジ時間 7,591 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 98 ms
4,380 KB
testcase_02 AC 130 ms
4,680 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 133 ms
4,732 KB
testcase_05 AC 78 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 80 ms
4,384 KB
testcase_08 AC 75 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 66 ms
4,384 KB
testcase_11 AC 92 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 126 ms
4,616 KB
testcase_14 AC 129 ms
4,800 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define MAX 100
#define MOD 998244353
#define INF 1000000000

int main(){
  int N;
  ll M,K;
  cin>>N>>M>>K;
  vector<ll> a(N);
  for(int i=0;i<N-1;i++){
    a[i]=(ll)i;
    M-=(ll)i;
  }
  a[N-1]=M;
  vector<ll> ans(N);
  for(int i=0;i<N;i++){
    if(K>=(ll)N-1-(ll)i){
      ans[i]=a[N-1-i];
      K-=(ll)N-1-(ll)i;
    }else{
      ll cnt=(ll)N-1-(ll)i;
      for(int j=0;j<N-i;j++){

        if(cnt==K){
          ans[i+j]=a[N-1-i];
          //cout<<i+j<<" "<<a[N-1-i]<<endl;
        }else if(cnt>K){
          ans[i+j]=a[j];
          //cout<<i+j<<" "<<a[j]<<endl;
        }else{
          ans[i+j]=a[j-1];
        }
        cnt--;
      }
      break;
    }
  }
  for(int i=0;i<N;i++){
    cout<<ans[i]<<endl;
  }
}
0