a814a54c34
I did not have fun These problems were very unenjoyable imo (skill issue probably)
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
int main() {
|
|
ios::sync_with_stdio(0);
|
|
cin.tie(0);
|
|
|
|
cin.ignore(6);
|
|
string line;
|
|
getline(cin, line);
|
|
istringstream sls(line);
|
|
vector<pair<long, long>> seeds;
|
|
vector<bool> done;
|
|
while (!sls.eof()) {
|
|
long n, nn;
|
|
sls >> n >> nn;
|
|
seeds.push_back(make_pair(n, n + nn - 1));
|
|
done.push_back(false);
|
|
}
|
|
cin.ignore(1);
|
|
|
|
for (int mapn = 0; mapn < 7; mapn++) {
|
|
cin.ignore(500, '\n');
|
|
while (getline(cin, line) && !line.empty()) {
|
|
istringstream sls(line);
|
|
long d, s, r;
|
|
sls >> d >> s >> r;
|
|
int ssize = seeds.size();
|
|
for (int i = 0; i < ssize; i++) {
|
|
if (done[i])
|
|
continue;
|
|
auto& curr = seeds[i];
|
|
long *curs = &get<0>(curr), *cure = &get<1>(curr);
|
|
if (*curs >= s) {
|
|
if (*cure < s + r) {
|
|
*curs += d - s;
|
|
*cure += d - s;
|
|
done[i] = true;
|
|
} else if (*curs < s + r) {
|
|
seeds.push_back(make_pair(*curs + d - s, d + r - 1));
|
|
done.push_back(true);
|
|
*curs = s + r;
|
|
}
|
|
} else if (*cure > s + r) {
|
|
seeds.push_back(make_pair(d, d + r - 1));
|
|
done.push_back(true);
|
|
seeds.push_back(make_pair(s + r, *cure));
|
|
done.push_back(false);
|
|
*cure = s - 1;
|
|
} else if (*cure > s) {
|
|
seeds.push_back(make_pair(d, *cure + d - s));
|
|
done.push_back(true);
|
|
*cure = s - 1;
|
|
}
|
|
}
|
|
}
|
|
fill(done.begin(), done.end(), false);
|
|
}
|
|
|
|
int min = INT_MAX;
|
|
for (auto& r : seeds) {
|
|
if (get<0>(r) < min)
|
|
min = get<0>(r);
|
|
}
|
|
cout << min << '\n';
|
|
}
|