Submission #1038219

#TimeUsernameProblemLanguageResultExecution timeMemory
1038219UnforgettableplTower (JOI24_tower)C++17
0 / 100
16 ms868 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int INF = 1e18+1; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,q,d,A,B; cin >> n >> q >> d >> A >> B; vector<pair<int,int>> ranges; for(int i=1;i<=n;i++){ int l,r;cin>>l>>r; ranges.emplace_back(l,r); } ranges.emplace_back(1e12+1,1e12+1); set<pair<int,int>> accessible; accessible.insert({0,ranges[0].first-1}); int last = d; for(int i=0;i<n;i++){ last = max(last,ranges[i].second+1); if(ranges[i].second-ranges[i].first+1>=d)break; if(last>=ranges[i+1].first)continue; accessible.insert({last,ranges[i+1].first-1}); last+=d; } accessible.insert({1e12+1,-1}); for(int i=1;i<=q;i++){ int x;cin>>x; if(accessible.lower_bound({x,-1})->second>=x)cout<<x<<'\n'; else cout << "-1\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...