-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathks-2022-walktober.cpp
More file actions
57 lines (45 loc) · 868 Bytes
/
Copy pathks-2022-walktober.cpp
File metadata and controls
57 lines (45 loc) · 868 Bytes
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
51
52
53
54
55
56
#include<bits/stdc++.h>
using namespace std;
int solve() {
int m, n, p;
// m - no of participants
// n - no of days
// p - last year ID of john
cin >> m >> n >> p;
vector<vector<int>> arr;
for (int i=0; i<m; i++) {
vector<int> temp;
for (int j=0; j<n; j++) {
int inp;
cin >> inp;
temp.push_back(inp);
}
arr.push_back(temp);
}
int ans = 0;
while (n--) {
int maxVal = 0;
int minVal = 60001;
for (int i=0; i < arr.size(); i++) {
maxVal = max(maxVal, arr[i][p]);
minVal = min(minVal, arr[i][p]);
}
ans += (maxVal - minVal);
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t, ts=1;
cin>>t;
while(t--)
{
cout<<"Case #" << ts << ": " << solve() <<"\n";
ts++;
}
return 0;
}