結果

問題 No.625 ソンタクロース
ユーザー kotatsugamekotatsugame
提出日時 2020-02-22 17:54:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 4,000 ms
コード長 571 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 77,672 KB
実行使用メモリ 7,412 KB
最終ジャッジ日時 2024-04-18 02:19:16
合計ジャッジ時間 2,002 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 13 ms
6,144 KB
testcase_18 AC 25 ms
7,412 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 21 ms
7,168 KB
testcase_23 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,M;
int A[1000][1000];
main()
{
	cin>>N>>M;
	A[0][0]=M;
	for(int i=1;i<N;i++)
	{
		vector<pair<int,int> >X;
		for(int j=0;j<i;j++)X.push_back(make_pair(A[i-1][j]+1,j));
		sort(X.begin(),X.end());
		int cnt=0;
		for(int j=0;j<(i+1)/2;j++)cnt+=X[j].first;
		if(cnt>M)
		{
			for(int j=0;j<i;j++)A[i][j]=A[i-1][j];
			A[i][i]=-1;
		}
		else
		{
			for(int j=0;j<(i+1)/2;j++)A[i][X[j].second]=X[j].first;
			A[i][i]=M-cnt;
		}
	}
	for(int i=0;i<N;i++)cout<<A[N-1][N-1-i]<<(i+1==N?"\n":" ");
}
0