QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#618660 | #2774. Scenery | Charizard2021 | WA | 0ms | 3828kb | C++14 | 2.3kb | 2024-10-07 02:41:43 | 2024-10-07 02:41:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, t;
cin >> n >> t;
vector<pair<int, int> > v(n);
vector<int> x;
for(int i = 0; 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(), x.end());
int idx = unique(x.begin(), x.end()) - x.begin();
vector<int> v2[idx];
for(int i = 1; i <= n; i++){
v[i].first = lower_bound(x.begin(), x.begin() + idx, v[i].first) - x.begin();
v[i].second = lower_bound(x.begin(), x.begin() + idx, v[i].second) - x.begin();
v2[v[i].first].push_back(v[i].second);
}
vector<int> counter(idx, 0);
vector<int> val1(idx);
for(int j = 0; j < idx; j++){
val1[j] = x[j];
}
vector<int> positions(idx, idx);
vector<int> things(idx, 1e9);
vector<int> cur(idx);
bool works = true;
for(int i = idx - 1; i >= 0; i--){
if(!v2[i].empty()){
for(int j = 0; 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 - 1; 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";
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3828kb
input:
2 10 0 15 5 20
output:
no
result:
wrong answer 1st lines differ - expected: 'yes', found: 'no'