-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker.cpp
50 lines (43 loc) · 1.03 KB
/
checker.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
39
40
41
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector<vector<int>> cl;
int calc(vector<int> &idx)
{
int maxi = 0;
int mini = 1e9;
for (int i = 0; i < 4; i++)
{
maxi = max(cl[i][idx[i]], maxi);
mini = min(cl[i][idx[i]], mini);
}
return maxi - mini;
}
int readAns(ifstream &fin)
{
vector<int> idx(4);
for(auto &x : idx) fin >> x;
auto sum = calc(idx);
return sum;
}
int main(int argc, char *argv[])
{
ifstream fin("input_file", ifstream::in);
ifstream ans("myAnswer", ifstream::in);
ifstream cor("correctAnswer", ifstream::in);
for (int i = 0; i < 4; i++){
int n; fin >> n;
vector<int> aux(n);
for(auto &x : aux) fin >> x;
sort(aux.begin(), aux.end());
cl.push_back(aux);
}
int myAnswer = readAns(ans);
int correctAnswer = readAns(cor);
if (myAnswer != correctAnswer)
{
cout << "different" << " " << correctAnswer << " " << myAnswer << endl;
return -1;
}
return 0;
}