結果
問題 |
No.2746 Bicolor Pyramid
|
ユーザー |
|
提出日時 | 2024-04-17 17:35:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 882 bytes |
コンパイル時間 | 1,926 ms |
コンパイル使用メモリ | 195,968 KB |
最終ジャッジ日時 | 2025-02-21 02:50:52 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 WA * 13 |
ソースコード
/* 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; int 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'; } }