結果

問題 No.1619 Coccinellidae
コンテスト
ユーザー kwm_t
提出日時 2021-07-22 23:19:30
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,458 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,284 ms
コンパイル使用メモリ 182,732 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-04-01 10:27:01
合計ジャッジ時間 2,308 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:58:22: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   58 |                 ans[i];
      |                      ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/vector:68,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/queue:69,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:160,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_vector.h:1261:7: note: declared here
 1261 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~

ソースコード

diff #
raw source code

#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
//const bool debug = false;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long n, m, k; cin >> n >> m >> k;
	vector<long long>ans(n, -1);
	int p = -1;
	rep(i, n) {
		long long x = n - 1 - i;
		if (k >= x) {
			ans[x] = i;
			k -= x;
		}
		else {
			ans[k] = i;
			k -= k;
		}
		if (0 == k) {
			p = i + 1;
			break;
		}
	}
	int r = 0;
	int maxpos = 0;
	rep2(i, p, n) {
		while (r < n) {
			if (-1 == ans[r]) break;
			r++;
		}
		ans[r] = i;
		maxpos = r;
		r++;
	}
	long long sum = 0;
	rep(i, n) {
		sum += ans[i];
		ans[i];
	}
	ans[maxpos] += m - sum;
	rep(i, n) cout << ans[i] << endl;
	return 0;
}
0