QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618665#2774. SceneryCharizard2021RE 0ms0kbC++142.4kb2024-10-07 02:46:222024-10-07 02:46:22

Judging History

你现在查看的是最新测评结果

  • [2024-10-07 02:46:22]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-07 02:46:22]
  • 提交

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;
    x.push_back(0);
    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() + 1, x.end());
    int idx = unique(x.begin() + 1, x.end()) - x.begin() - 1;
    vector<int> v2[idx];
    for(int i = 0; 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

output:


result: