結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー aradarad
提出日時 2022-08-05 21:26:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,449 bytes
コンパイル時間 3,957 ms
コンパイル使用メモリ 259,376 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 21:49:57
合計ジャッジ時間 8,823 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 242 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 248 ms
4,352 KB
testcase_05 AC 250 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 53 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 116 ms
4,352 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 60 ms
4,348 KB
testcase_14 WA -
testcase_15 AC 106 ms
4,348 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 144 ms
4,352 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 42 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VS = vector<string>;
using VVS = vector<VS>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcount
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//const int INF = 1001001001;
const ll INF = 1e18;
//using mint = modint1000000007;
//using mint = modint998244353;
int di[8] = {0,0,-1,1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

int main(){
    ll n,s;
    cin >> n >> s;
    for(ll i = 0;i <= n;i++){
        ll l = i*(i+1)/2;
        ll ng = i,ok = n+1;
        while(ok-ng > 1){
            ll x = (ng+ok)/2;
            if(x*(x+1)/2-l >= s) ok = x;
            else ng = x; 
        }
        if(ok == n+1) continue;
        if(ok*(ok+1)/2-l == s){
            cout << ok-i << endl;
            for(int j = i+1;j <= ok;j++) cout << j << endl;
            re0;
        }
    }
    out(-1);
}
0