# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321451 | tjdgus4384 | 장애물 경기 (KOI16_dd) | C++14 | 94 ms | 6848 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int N, x, y, a, b, c;
set<pair<int, long long> > s;
vector<pair<int, pair<int, int> > > v;
int main(){
scanf("%d", &N);
scanf("%d %d", &x, &y);
s.insert({x, 0});
for(int i = 0;i < N;i++){
scanf("%d %d %d", &a, &b, &c);
v.push_back({a, {b, c}});
}
sort(v.begin(), v.end());
for(int i = 0;i < N;i++){
a = v[i].first;
b = v[i].second.first;
c = v[i].second.second;
set<pair<int, long long> >::iterator it;
it = s.lower_bound({b+1, 0});
vector<pair<int, long long> > m1, m2;
while(it != s.end()){
int yt = (*it).first;
if(yt >= c) break;
long long len = (*it).second;
m1.push_back({b, len+(long long)yt-(long long)b});
m2.push_back({c, len+(long long)c-(long long)yt});
set<pair<int, long long> >::iterator tmp = it;
it++;
s.erase(tmp);
}
if(!m1.empty()){
sort(m1.begin(), m1.end());
sort(m2.begin(), m2.end());
s.insert(m1.front());
s.insert(m2.front());
}
}
set<pair<int, long long> >::iterator it;
long long ans = 1e18, cnt = 0;
vector<int> chk;
it = s.begin();
while(it != s.end()){
if(ans == (*it).second){
cnt++; chk.push_back((*it).first);
}
else if(ans > (*it).second){
ans = (*it).second;
cnt = 1; chk.clear(); chk.push_back((*it).first);
}
it++;
}
printf("%lld\n%d", ans+y, cnt);
for(int i = 0;i < chk.size();i++){
printf(" %d", chk[i]);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |