제출 #1291096

#제출 시각아이디문제언어결과실행 시간메모리
1291096lmaobruhRoses (BOI20_roses)C++20
20 / 100
337 ms580 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;
}

inline ll cal(ll x) {
    return min(calc(x,a,b),calc(x,c,d));
}

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)) {
        if (1ll * i * c > n) break;
        mini(ans, 1ll * i * d + cal(n - 1ll * i * c));
    }
    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;
}

컴파일 시 표준 에러 (stderr) 메시지

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