-
Notifications
You must be signed in to change notification settings - Fork 0
/
combo.cpp
38 lines (34 loc) · 827 Bytes
/
combo.cpp
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
/*
ID: ...
PROG: combo
LANG: C++11
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ofstream fout ("combo.out");
ifstream fin ("combo.in");
int N;
int a[3];
int b[3];
fin >> N;
fin >> a[0] >> a[1] >> a[2];
fin >> b[0] >> b[1] >> b[2];
int common[3];
for (int i = 0; i < 3; i++) {
common[i] = 5 - max(a[i], b[i]) + min(a[i], b[i]);
if ((common[i]) < 0 || common[i] > 5) {
common[i] = 5 - min(a[i] + N, b[i]+N) + max(a[i], b[i]);;
if (common[i] < 0 || common[i] > 5) {
common[i] = 0;
}
}
common[i] = min(common[i], N);
}
int k = min(5, N);
int result = 2 * k * k * k - common[0]*common[1]*common[2];
fout << result << endl;
return 0;
}