답안 #1030768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030768 2024-07-22T09:45:44 Z Antekb Tower (JOI24_tower) C++17
0 / 100
27 ms 2584 KB
#include "bits/stdc++.h"	/** keep-include */
using namespace std;

#define rep(i, b, e) for(int i = (b); i <= (e); i++)
#define per(i, b, e) for(int i = (e); i >= (b); i--)
#define FOR(i, b, e) rep(i, b, (e) - 1)
#define SZ(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

auto &operator<<(auto &o, pair<auto, auto> p) {
	return o << "(" << p.st << ", " << p.nd << ")"; }
auto operator<<(auto &o, auto x)->decltype(end(x), o) {
	o << "{"; int i=0; for(auto e: x) o << ", " + 2*!i++ << e;
	return o << "}"; }
#ifdef LOCAL
#define deb(x...) cerr << "[" #x "]: ", [](auto...$) { \
	((cerr << $ << "; "),...) << endl; }(x)
#else
#define deb(...)
#endif

void solve() {
	int n, q;
    cin>>n>>q;
    ll A, B, D;
    cin>>D>>A>>B;
    vector<pair<ll ,ll>> seg;
    for(int i=0; i<n; i++){
        ll l, r;
        cin>>l>>r;
        r=max(r, D-1);
        if(i==0){
            seg.pb(mp(l, r));
        }
        else if(l<=seg.back().nd+1){
            seg.back().nd=r;
        }
        else{
            seg.pb(mp(l, r));
            int t=lower_bound(all(seg), mp(r+2-D,0ll))-seg.begin();
            t--;
            if(t>=0){
                seg.back().nd=max(r, seg[t].nd+D);
            }
        }
    }
    deb(seg);
    while(q--){
        ll x;
        cin>>x;
        int t=lower_bound(all(seg), mp(x+1, 0ll))-seg.begin();
        t--;
        if(t>=0 && seg[t].nd>=x){
            cout<<"-1\n";
            continue;
        }
        cout<<x<<"\n";
    }
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int tt = 1;
	// cin >> tt;
	FOR(te, 0, tt) solve();
	return 0;
}

Compilation message

Main.cpp:17:18: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   17 | auto &operator<<(auto &o, pair<auto, auto> p) {
      |                  ^~~~
Main.cpp:17:32: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   17 | auto &operator<<(auto &o, pair<auto, auto> p) {
      |                                ^~~~
Main.cpp:17:38: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   17 | auto &operator<<(auto &o, pair<auto, auto> p) {
      |                                      ^~~~
Main.cpp:19:17: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | auto operator<<(auto &o, auto x)->decltype(end(x), o) {
      |                 ^~~~
Main.cpp:19:26: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | auto operator<<(auto &o, auto x)->decltype(end(x), o) {
      |                          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 2584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -