6204 | 2023-11-08 08:28:02 | EsVagy | Bevásárlás | cpp17 | Accepted 100/100 | 3ms | 3852 KiB |
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
const int prices[] = { 300, 350, 400 };
int a, b, c;
cin >> a >> b >> c;
int counts[] = { a, b, c };
int p = 10;
int price = 0;
for (int i = 0; i < 3; i++)
{
int bought = min(counts[i], p);
price += bought * prices[i];
p -= bought;
if (p == 0)
{
break;
}
}
if (p != 0)
{
price = -1;
}
cout << price;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1880 KiB | ||||
2 | Accepted | 3ms | 2112 KiB | ||||
3 | Accepted | 3ms | 2280 KiB | ||||
subtask2 | 10/10 | ||||||
4 | Accepted | 2ms | 2396 KiB | ||||
5 | Accepted | 3ms | 2516 KiB | ||||
6 | Accepted | 3ms | 2728 KiB | ||||
subtask3 | 20/20 | ||||||
7 | Accepted | 2ms | 2788 KiB | ||||
8 | Accepted | 2ms | 2908 KiB | ||||
9 | Accepted | 3ms | 2928 KiB | ||||
10 | Accepted | 2ms | 3036 KiB | ||||
subtask4 | 30/30 | ||||||
11 | Accepted | 2ms | 3240 KiB | ||||
12 | Accepted | 2ms | 3328 KiB | ||||
13 | Accepted | 2ms | 3320 KiB | ||||
14 | Accepted | 2ms | 3472 KiB | ||||
subtask5 | 40/40 | ||||||
15 | Accepted | 2ms | 3508 KiB | ||||
16 | Accepted | 3ms | 3540 KiB | ||||
17 | Accepted | 2ms | 3484 KiB | ||||
18 | Accepted | 2ms | 3484 KiB | ||||
19 | Accepted | 2ms | 3608 KiB | ||||
20 | Accepted | 3ms | 3852 KiB |