Submission #1015044

#TimeUsernameProblemLanguageResultExecution timeMemory
1015044djs100201쌍둥이 독수리 (GA7_twineagles)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx2") #define all(v) v.begin(),v.end() using namespace std; using ll = long long; using P = pair<ll, ll>; using PP = pair<ll, P>; const ll n_ =1e5+100, inf = (ll)2e9 * (ll)1e9 + 7, mod = 998244353; ll n, m, tc = 1, a, b, c, d, sum, x, y, z, base, ans, k; ll gcd(ll x,ll y){ if(!y)return x; return gcd(y,x%y); } //추가 일수 최소.... bool can; ll get(ll dmg,ll hp,ll heal){ if(dmg>=hp){ if(dmg/2>=hp)can=true; return 1; } if(dmg<=heal) return inf; ll l=1,r=2e9,ret=inf; while(l<=r){ ll mid=(l+r)/2; if((heal-dmg)<=(dmg-hp)/mid){ ret=min(ret,mid); r=mid-1; } else l=mid+1; } if((heal-dmg)<=(dmg/2-hp)/ret)can=true; return ret+1; } void solve(){ ll LH,S,D,L,B; cin>>LH>>S>>D>>L>>B; //if(D>=S)swap(S,D),swap(L,B); //항상 S<=D임... ans=inf; can=false; x=get(LH*2,S,L); if(can){ if(D+(x-1)*B<=LH)ans=min(ans,x); ans=min(ans,x+get(LH*2,D+x*B-LH,B)); } else { ans=min(ans,x+get(LH*2,D+x*B,B)); } can=false; x=get(LH*2,D,B); if(can){ if(S+(x-1)*L<=LH)ans=min(ans,x); ans=min(ans,x+get(LH*2,S+x*L-LH,L)); } else ans=min(ans,x+get(LH*2,S+x*L,L)); cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); //cin >> tc; while (tc--)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...