結果

問題 No.2746 Bicolor Pyramid
ユーザー otoshigootoshigo
提出日時 2024-04-20 14:00:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,329 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 196,336 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 14:00:20
合計ジャッジ時間 3,374 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 WA -
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

vector<int>A={0,1,4,5,9,10,13,14,16,17,20,21,25,26,29,30,34,35,36,37,38,39,40,41,42,45,46,49,50,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,68,69,70,71,73,74,75,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,93,94,95,97,98,99,100,101,102,103,104,105,106,107,109,110,111,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,129};


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll R,B;
    cin>>R>>B;
    ll ok=0,ng=2e9;
    while(ng-ok>1){
        ll mid=(ok+ng)/2;
        if(mid*(mid+1)>(R+B+2*mid)/(2*mid+1)*6)ng=mid;
        else{
            ll al=mid*(mid+1)*(2*mid+1)/6;
            if(R>=129){
                if(al-R<=B)ok=mid;
                else ng=mid;
            }
            else{
                auto id=lower_bound(all(A),R);
                if(*id!=R)id--;
                if(al-*id<=B)ok=mid;
                else ng=mid;
            }
        }
    }
    cout<<ok<<"\n";
}
0