Submission #1038668

# Submission time Handle Problem Language Result Execution time Memory
1038668 2024-07-30T05:49:23 Z 김은성(#10985) Tower (JOI24_tower) C++17
0 / 100
26 ms 2536 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[200009], l[200009], r[200009];
int main(){
    int n, t, i, j=0;
    ll d, a, b;
    scanf("%d %d", &n, &t);
    scanf("%lld %lld %lld", &d, &a, &b);
    for(i=1; i<=n; i++){
        scanf("%lld %lld", &l[i], &r[i]);
        l[i]--;
        r[i]++;
    }
    l[n+1] = (ll)1e16;
    dp[0] = 0;
    deque<int> q;
    q.push_back(0);
    for(i=1; i<=n; i++){
        while(l[j+1] < r[i] - d){
            if(q.front() == j)
                q.pop_front();
            j++;
        }
        if(q.empty())
            dp[i] = -1;
        else{
            dp[i] = max(dp[q.front()] + d, r[i]);
            if(dp[i] > l[n+1])
                dp[i] = -1;
            else
                q.push_back(i);
        }
        //printf("dp[%d]=%lld\n", i, dp[i]);
    }
    for(i=1; i<=t; i++){
        ll x;
        scanf("%lld", &x);
        int idx = lower_bound(l+1, l+n+1, x) - l;
        idx--;
        if(dp[idx] > x)
            printf("-1\n");
        else
            printf("%lld\n", x);
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d %d", &n, &t);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%lld %lld %lld", &d, &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%lld %lld", &l[i], &r[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         scanf("%lld", &x);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 2536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -