Submission #1015063

#TimeUsernameProblemLanguageResultExecution timeMemory
1015063djs100201쌍둥이 독수리 (GA7_twineagles)C++17
52 / 100
1 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)4e9 * (ll)2e9 + 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=1e9,ret=inf; while(l<=r){ ll mid=(l+r)/2; ll R=(hp-dmg)/mid; if((hp-dmg)%mid)R++; if((dmg-heal)>=R){ ret=min(ret,mid); r=mid-1; } else l=mid+1; } ll R=(hp-dmg/2)/ret; if((hp-dmg/2)%ret)R++; if((dmg-heal)>=R)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(x!=inf){ if(can){ if(D+(x-1)*B<=LH)ans=min(ans,x); else ans=min(ans,x+get(LH*2,D+x*B-LH,B)); } else { ans=min(ans,x+get(LH*2,D+x*B,B)); } } swap(S,D),swap(L,B); can=false; x=get(LH*2,S,L); if(x!=inf){ if(can){ if(D+(x-1)*B<=LH)ans=min(ans,x); else ans=min(ans,x+get(LH*2,D+x*B-LH,B)); } else { ans=min(ans,x+get(LH*2,D+x*B,B)); } } 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...