結果

問題 No.625 ソンタクロース
ユーザー Sebastian King
提出日時 2017-12-25 22:30:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 25 ms / 4,000 ms
コード長 1,324 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 165,760 KB
実行使用メモリ 12,116 KB
最終ジャッジ日時 2024-12-17 20:21:02
合計ジャッジ時間 2,917 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0