QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#618666 | #2774. Scenery | Charizard2021 | RE | 0ms | 0kb | C++14 | 2.4kb | 2024-10-07 02:48:12 | 2024-10-07 02:48:13 |
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, t;
cin >> n >> t;
vector<pair<int, int> > v(1 + n);
vector<int> x;
x.push_back(0);
for(int i = 1; i <= n; i++){
cin >> v[i].first >> v[i].second;
x.push_back(v[i].first);
x.push_back(v[i].second);
}
sort(x.begin() + 1, x.end());
int idx = unique(x.begin() + 1, x.end()) - x.begin() - 1;
vector<int> v2[idx];
for(int i = 1; i <= n; i++){
v[i].first = lower_bound(x.begin() + 1, x.begin() + idx+ 1, v[i].first) - x.begin();
v[i].second = lower_bound(x.begin() + 1, x.begin() + idx + 1, v[i].second) - x.begin();
v2[v[i].first].push_back(v[i].second);
}
vector<int> counter(1 + idx, 0);
vector<int> val1(1 + idx);
for(int j = 1; j <= idx; j++){
val1[j] = x[j];
}
vector<int> positions(1 + idx, idx);
vector<int> things(1 + idx, 1e9);
vector<int> cur(1 + idx);
bool works = true;
for(int i = idx; i >= 1; i--){
if(!v2[i].empty()){
for(int j = 1; j <= idx; j++){
cur[j] = things[j];
}
for(int j : v2[i]){
for(int k = j; k <= idx; k++){
counter[k]++;
}
}
for(int j = idx; j >= i; j--){
for(int a = 0; a < counter[j]; a++){
val1[j] -= t;
while(positions[j] && val1[j] < x[positions[j]]){
if(val1[j] < x[i]){
works = false;
break;
}
val1[j] = min(val1[j], cur[positions[j]]);
positions[j]--;
}
if(!works){
break;
}
if(val1[j] < x[i]){
works = false;
break;
}
things[i] = min(things[i], val1[j] - t);
}
if(!works){
break;
}
counter[j] = 0;
}
if(!works){
break;
}
}
if(!works){
break;
}
}
if(works){
cout << "yes\n";
}
else{
cout << "no\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
2 10 0 15 5 20