結果

問題 No.648  お や す み 
ユーザー prtoq3
提出日時 2018-10-27 23:35:59
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 524 bytes
コンパイル時間 2,561 ms
コンパイル使用メモリ 159,160 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-19 06:52:58
合計ジャッジ時間 4,268 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 67
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1000000010;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

ll n;

bool C(ll k){
    double sum = k * (k + 1) / 2;
    return sum >= n;
}

int main(){
    cin >> n;

    ll ng = 0;
    ll ok = INF;
    
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if (C(mid)) ok = mid;
        else ng = mid;
    }

    if (ok < INF) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}
0