結果
| 問題 |
No.2027 (1, 2, 3, …, N) 's Subset Sum
|
| コンテスト | |
| ユーザー |
rieaaddlreiuu
|
| 提出日時 | 2022-11-05 13:13:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 2,000 ms |
| コード長 | 436 bytes |
| コンパイル時間 | 1,624 ms |
| コンパイル使用メモリ | 166,920 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 07:03:56 |
| 合計ジャッジ時間 | 3,499 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 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\n",x);
} else {
printf("%d\n",x-1);
}
for(long i=1;i<=x;i++){
if(i != x*(x+1)/2 - S){
printf("%ld ",i);
}
}
}
rieaaddlreiuu