-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalentinesday.cpp
More file actions
50 lines (36 loc) · 1.07 KB
/
Copy pathvalentinesday.cpp
File metadata and controls
50 lines (36 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// NOTE: it is recommended to use this even if you don't understand the following code.
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct pacco {
int quantita;
int prezzo;
bool operator< (pacco & right) {
pacco left = *this;
return left.prezzo < right.prezzo || (left.prezzo == right.prezzo && left.quantita < right.quantita);
}
};
int main() {
// uncomment the two following lines if you want to read/write from files
// ifstream cin("input.txt");
// ofstream cout("output.txt");
int N, M;
cin >> N >> M;
vector<pacco> c(N);
for (int i = 0; i < N; ++i)
cin >> c[i].quantita;
for (int i = 0; i < N; ++i)
cin >> c[i].prezzo;
int maxChocolates = 0;
// INSERT YOUR CODE HERE
sort (c.begin(), c.end());
for (int i=0; i<N; i++) {
if (c[i].prezzo <= M) {if (c[i].quantita % 2 == 0) maxChocolates = max(c[i].quantita, maxChocolates);}
else break;
}
cout << maxChocolates << endl;
return 0;
}