Submission #1291097

#TimeUsernameProblemLanguageResultExecution timeMemory
1291097lmaobruhRoses (BOI20_roses)C++20
20 / 100
85 ms584 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define eb emplace_back #define pb push_back #define fi first #define se second #define ii pair<int,int> #define ve vector #define all(x) x.begin(), x.end() #define fo(i,a,b) for (int i=(a); i<=(b); ++i) #define fd(i,a,b) for (int i=(a); i>=(b); --i) #define maxi(a, b) a = max(a, b) #define mini(a, b) a = min(a, b) #define _ << ' ' << const int N = 2e7+5, inf = 1e9+10, mod = 1e9+7; const ll inf64=1e18+1; /** **/ ll n, a, b, c, d; inline ll calc(ll x, ll num, ll cost) { ll tt = (x + num - 1) / num; if (tt>=inf64/cost||cost*tt>=inf64) return inf64; return cost*tt; } void sol() { cin >> n >> a >> b >> c >> d; if (1ll * b * c >= 1ll * a * d) swap(a, c), swap(b, d); ll ans = inf; fo(i,0,min(n,(ll)1e8)) { mini(ans, 1ll * i * d + calc(n - 1ll * i * c, a, b)); if (1ll * i * c > n) break; } cout<<ans; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); if(fopen("A.inp","r")) { freopen("A.inp","r",stdin); freopen("A.out","w",stdout); } int tc = 1; // cin >> tc; fo(i,1,tc) sol(); return 0; }

Compilation message (stderr)

Roses.cpp: In function 'int main()':
Roses.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         freopen("A.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
Roses.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         freopen("A.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...