結果

問題 No.2746 Bicolor Pyramid
ユーザー hiikunZhiikunZ
提出日時 2024-04-20 20:25:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,591 bytes
コンパイル時間 2,379 ms
コンパイル使用メモリ 198,380 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 20:25:37
合計ジャッジ時間 3,407 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
constexpr ll MAX = 2000000000000000000;
constexpr ld PI = 3.14159265358979;
constexpr ll MOD = 0;//2024948111;
ld dotorad(ld K){ return PI * K / 180.0; }
ld radtodo(ld K){ return K * 180.0 / PI; }
mt19937 mt;
void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); }
int main(){
    ll R,B;
    cin >> R >> B;
    vector<ll> muri = {2,3,6,7,8,11,12,15,18,19,22,23,24,27,28,31,32,33,43,44,47,48,60,67,72,76,92,96,108,112,128,MAX};
    while(1){
        ll p = *lower_bound(muri.begin(),muri.end(),R);
        if(p != R) break;
        R--;
    }
    while(1){
        ll p = *lower_bound(muri.begin(),muri.end(),B);
        if(p != B) break;
        B--;
    }
    if(R + B < 506){
        for(ll n = 12;n >= 1;n--){
            for(ll bit = 0;bit < (1LL << n);bit++){
                ll a = 0,b = 0;
                for(ll i = 0;i < n;i++){
                    if(bit & (1LL << i)){
                        a += (i + 1) * (i + 1);
                    }
                    else{
                        b += (i + 1) * (i + 1);
                    }
                }
                if(a <= R && b <= B){
                    cout << n << endl;
                    return 0;
                }
            }
        }
    }
    ll a = 0;
    for(ll i = 1;i <= 1817121;i++){
        if(a + i * i > R + B){
            cout << i - 1 << endl;
            return 0;
        }
        a += i * i;
    }
}
0