結果

問題 No.625 ソンタクロース
ユーザー Sebastian KingSebastian King
提出日時 2017-12-25 22:30:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 21 ms / 4,000 ms
コード長 1,324 bytes
コンパイル時間 2,614 ms
コンパイル使用メモリ 152,364 KB
実行使用メモリ 10,728 KB
最終ジャッジ日時 2023-08-22 19:29:37
合計ジャッジ時間 2,458 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 5 ms
6,612 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 11 ms
8,668 KB
testcase_18 AC 21 ms
10,640 KB
testcase_19 AC 5 ms
6,608 KB
testcase_20 AC 5 ms
6,536 KB
testcase_21 AC 4 ms
6,620 KB
testcase_22 AC 18 ms
10,728 KB
testcase_23 AC 3 ms
4,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e3 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN][MAXN];

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	cin >> n >> m;
	if (n == 1 || n == 3){
		cout << m;
		for (int i = 1; i < n; i++)
			cout << " 0";
		cout << endl;
		return ;
	}
	if (n == 2){
		cout << -1 << ' ' << m << endl;
		return ;
	}
	a[3][1] = 0;
	a[3][2] = 0;
	a[3][3] = m;
	int k = 3;
	for (int x = 4; x <= n; x++){
		k = x;
		int y = x - 1;
		vector<PII> f;
		for (int i = 1; i <= y; i++){
			f.push_back(PII(a[y][i] + 1, i));
		}
		sort(f.begin(), f.end());
		int cnt = 0, mm = x / 2;
		for (int i = 0; i < mm; i++)
			cnt += (a[x][f[i].second] = f[i].first);
		if (cnt <= m){
			a[x][x] = m - cnt;
		}
		else{
			a[y][x] = -1;
			for (int i = x + 1; i <= n; i++)
				a[y][i] = -1;
			k = y;
			break;
		}
		//for (int i = 1; i <= x; i++)
		//	cout << a[x][i] << ' '; cout << endl;
	}
	for (int i = n; i >= 2; i--)
		cout << a[k][i] << ' ';
	cout << a[k][1] << endl;
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

0