제출 #1038235

#제출 시각아이디문제언어결과실행 시간메모리
1038235UnforgettableplTower (JOI24_tower)C++17
0 / 100
26 ms2308 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; int last2 = ranges[0].first-1+d; for(int i=0;i<n;i++){ last = max(last,ranges[i].second+1); if(last2<=ranges[i].second)break; if(last>=ranges[i+1].first)continue; accessible.insert({last,ranges[i+1].first-1}); last+=d; last2 = ranges[i+1].first-1+d; } for(int i=1;i<=q;i++){ int x;cin>>x; auto iter = accessible.upper_bound({x,INF}); if(iter==accessible.begin()) cout << "-1\n"; else { iter--; if(x<=iter->second)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...