답안 #642276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642276 2022-09-19T07:13:23 Z Kenpar Roses (BOI20_roses) C++17
0 / 100
0 ms 300 KB
//Segment Tree Degil Bu What

#include "bits/stdc++.h"
using namespace std;

#define ll long long

const ll MOD = 1e9+7;
const ll MAX = 2e5+1;

void solve(){
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;

	ll ans1 = 0, ans2 = 0;
	long double first = ((long double)b)/a, second = ((long double)d)/c;

	if(first > second){
		ans1 = (n / c) * d;

		n-=((n / c) * c );

		if(n == 0){
			cout<<ans1;
			return;
		}

		ans2 = ans1;

		ans1 += d;

		ans2 += (n / a) * b;

		n-= (n / a) * a;

		if(n != 0){
			ans2+= b;
		}

		cout << min(ans1,ans2);
	}else{
		ans1 = (n / a) * b;

		n-=((n / a) * b );

		if(n == 0){
			cout<<ans1;
			return;
		}

		ans2 = ans1;

		ans1 += b;

		ans2 += (n / c) * d;

		n-= (n / c) * c;

		if(n != 0){
			ans2+= d;
		}

		cout << min(ans1,ans2);
	}
}


int main()
{
	int t = 1;

	//cin >> t;

	while(t--){
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -