結果

問題 No.1619 Coccinellidae
ユーザー tnakao0123tnakao0123
提出日時 2021-07-24 01:24:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,134 bytes
コンパイル時間 903 ms
コンパイル使用メモリ 91,096 KB
実行使用メモリ 5,104 KB
最終ジャッジ日時 2023-09-26 06:37:24
合計ジャッジ時間 3,177 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1619.cc:  No.1619 Coccinellidae - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;

/* global variables */

ll as[MAX_N], ps[MAX_N];
bool used[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  ll m, k;
  scanf("%d%lld%lld", &n, &m, &k);

  ll s = (ll)n * (n - 1) / 2;
  ll a0 = (m - s) / n;

  for (int i = 0; i < n; i++) as[i] = a0 + i;
  as[n - 1] += m - (s + (ll)a0 * n);
  //for (int i = 0; i < n; i++) printf("%lld ", as[i]); putchar('\n');

  int l = 0;
  for (int i = n - 1; i >= 0; i--)
    if (k >= i) {
      ps[l++] = i;
      used[i] = true;
      k -= i;
    }

  for (int i = 0; i < n; i++)
    if (! used[i]) ps[l++] = i;

  for (int i = 0; i < n; i++) printf("%lld\n", as[ps[i]]);
  return 0;
}
0