結果
| 問題 |
No.2027 (1, 2, 3, …, N) 's Subset Sum
|
| コンテスト | |
| ユーザー |
rieaaddlreiuu
|
| 提出日時 | 2022-11-05 13:09:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 431 bytes |
| コンパイル時間 | 1,548 ms |
| コンパイル使用メモリ | 165,068 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-19 07:01:35 |
| 合計ジャッジ時間 | 7,603 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
long S;
scanf("%d %ld",&N,&S);
long x = 1;
while(1){
if(x*(x-1)/2 < S && S <= x*(x+1)/2){
break;
}
x++;
}
if(S == x*(x+1)/2){
printf("%d",x);
} else {
printf("%d",x-1);
}
for(long i=0;i<x;i++){
if(i != x*(x+1)/2 - S){
printf("%ld ",i);
}
}
}
rieaaddlreiuu