結果

問題 No.625 ソンタクロース
ユーザー 👑 kmjpkmjp
提出日時 2017-12-25 00:29:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 4,000 ms
コード長 1,288 bytes
コンパイル時間 1,378 ms
コンパイル使用メモリ 152,248 KB
実行使用メモリ 7,692 KB
最終ジャッジ日時 2023-08-22 18:07:54
合計ジャッジ時間 2,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,652 KB
testcase_01 AC 5 ms
7,684 KB
testcase_02 AC 4 ms
7,488 KB
testcase_03 AC 4 ms
7,460 KB
testcase_04 AC 4 ms
7,580 KB
testcase_05 AC 4 ms
7,476 KB
testcase_06 AC 4 ms
7,692 KB
testcase_07 AC 4 ms
7,456 KB
testcase_08 AC 5 ms
7,564 KB
testcase_09 AC 5 ms
7,500 KB
testcase_10 AC 5 ms
7,560 KB
testcase_11 AC 4 ms
7,516 KB
testcase_12 AC 4 ms
7,484 KB
testcase_13 AC 5 ms
7,564 KB
testcase_14 AC 5 ms
7,620 KB
testcase_15 AC 6 ms
7,508 KB
testcase_16 AC 5 ms
7,524 KB
testcase_17 AC 13 ms
7,660 KB
testcase_18 AC 23 ms
7,472 KB
testcase_19 AC 7 ms
7,564 KB
testcase_20 AC 8 ms
7,464 KB
testcase_21 AC 6 ms
7,464 KB
testcase_22 AC 20 ms
7,592 KB
testcase_23 AC 6 ms
7,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int P[1010][1010];

int R[1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	
	MINUS(P);
	if(N==1) return _P("%d\n",M);
	if(N==2) return _P("-1 %d\n",M);
	if(N==3) return _P("%d 0 0\n",M);
	P[3][0]=P[3][1]=0;
	P[3][2]=M;
	for(i=4;i<=N;i++) {
		vector<pair<int,int>> cand;
		FOR(j,i-1) cand.push_back({P[i-1][j],j});
		sort(ALL(cand));
		FOR(j,i-1) P[i][j]=0;
		int left=M;
		FOR(j,i/2) {
			x=cand[j].second;
			P[i][x]=P[i-1][x]+1;
			left-=P[i][x];
		}
		P[i][i-1]=left;
		if(P[i][i-1]<0) break;
	}
	
	x=N;
	while(P[x][x-1]<0) x--;
	
	FOR(i,N) _P("%d%c",P[x][N-1-i],(i==N-1)?'\n':' ');
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0