Submission #574083

# Submission time Handle Problem Language Result Execution time Memory
574083 2022-06-07T18:25:12 Z MODDI Roses (BOI20_roses) C++14
0 / 100
1 ms 300 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
ll lcm(ll a, ll b){
	return (a * b / __gcd(a,b));
}
int main(){
	ll n, a, b, c, d;
	cin>>n>>a>>b>>c>>d;
	ll t = lcm(a, c);
	ll ans = 0;
	if((t/a)*b <= (t/c)*d){
		ll can = n / a;
		ans += can * b;
		n -= can * a;
		ll canA = n / a;
		if(n % a != 0)
			canA++;
		ll canC = n / c;
		if(n % c != 0)
			canC++;
		if(canA * b < canC * d){
			ans += canA * b;
		}
		else
			ans += canC * d;
	}
	else{
		ll can = n / c;
		ans += can * d;
		n -= can * c;
		ll canA = n / a;
		if(n % a != 0)
		canA++;
		ll canC = n / c;
		if(n % c != 0)
		canC++;
		if(canA * b < canC * d){
			ans += canA * b;
		}
		else
			ans += canC * d;
	}
	cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -