-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.cpp
More file actions
46 lines (41 loc) · 1.63 KB
/
info.cpp
File metadata and controls
46 lines (41 loc) · 1.63 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
#include "info.h"
int nVideos;
int nEndpoints;
int nRequestsDescriptions;
int nCaches;
int nCacheCapacity;
vector<int> videoSizes;
vector<Endpoint> endpoints;
vector<RequestDescription> requestDescriptions;
void readInput() {
cin >> nVideos >> nEndpoints >> nRequestsDescriptions >> nCaches >> nCacheCapacity;
videoSizes.resize(nVideos);
for (int i = 0; i < nVideos; i++) {
cin >> videoSizes[i];
}
endpoints.resize(nEndpoints);
for (int i = 0 ; i < nEndpoints; i++) {
cin >> endpoints[i].latencyToBase;
int k;
cin >> k;
endpoints[i].cachesConnectedToThisEndpoint.resize(k);
for (int j = 0; j < k; j++) {
cin >> endpoints[i].cachesConnectedToThisEndpoint[j].cacheId;
cin >> endpoints[i].cachesConnectedToThisEndpoint[j].cacheLatency;
}
sort(endpoints[i].cachesConnectedToThisEndpoint.begin(), endpoints[i].cachesConnectedToThisEndpoint.end(), [&](const pair<int,int>& a, const pair<int,int>& b) {return a.cacheLatency < b.cacheLatency;});
}
cerr << "reading endpoints done" << endl;
map<pair<int,int>, int> tmp;
for (int i = 0; i < nRequestsDescriptions; i++) {
int a,b,c;
cin >> a >> b >> c;
auto pr = make_pair(a, b);
tmp[pr] += c;
}
nRequestsDescriptions = tmp.size();
for (auto i : tmp) {
requestDescriptions.emplace_back(RequestDescription{i.first.first, i.first.second, i.second});
}
sort(requestDescriptions.begin(), requestDescriptions.end(), [&](const RequestDescription& a, const RequestDescription& b) {return a.numberOfRequests > b.numberOfRequests;});
}