結果
| 問題 | No.2746 Bicolor Pyramid |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-17 17:39:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 881 bytes |
| 記録 | |
| コンパイル時間 | 1,991 ms |
| コンパイル使用メモリ | 196,596 KB |
| 最終ジャッジ日時 | 2025-02-21 02:51:04 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 WA * 1 TLE * 1 -- * 21 |
ソースコード
/*
https://yukicoder.me/submissions/973056
C++移植
*/
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int MOD=998244353;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll B,R;
cin>>R>>B;
if(R<B)swap(R,B);
if(B>128){
ll ans=0,S=0;
while(S+(ans+1)*(ans+1)<=R+B){
ans+=1;
S+=ans*ans;
}
cout<<ans<<'\n';
}else{
vector dp(B+1,0);
dp[0]=1;
ll k=1,z=0;
while(1){
bool flag=0;
vector ndp(B+1,0);
swap(dp,ndp);
for(int i=0;i<=B;i++){
if(!ndp[i])continue;
int j=z-i;
if(i+k*k<=B && j+k*k<=R){
dp[i+k*k]=1;
flag=1;
}
if(i<=B && j+k*k<=R){
dp[i]=1;
flag=1;
}
}
if(flag){
z+=k*k;
k+=1;
}else{
break;
}
}
cout<<k-1<<'\n';
}
}