이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
const int nmax = 3e5 + 1;
const ll linf = 1e18 + 1;
vector <ll> t(4 * nmax, linf);
void update(int v, int l, int r, int pos, ll val){
    if(l > pos || r < pos) return;
    if(l == r){
        t[v] = val;
        return;
    }
    int m = (l + r) / 2;
    update(2 * v, l, m, pos, val);
    update(2 * v + 1, m + 1, r, pos, val);
    t[v] = min(t[2 * v], t[2 * v + 1]);
}
ll get(int v, int l, int r, int st, int fin){
    if(l > fin || r < st) return linf;
    if(l >= st && r <= fin){
        return t[v];
    }
    int m = (l + r) / 2;
    return min(get(2 * v, l, m, st, fin),
               get(2 * v + 1, m + 1, r, st, fin));
}
int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    int m, n; cin >> m >> n;
    vector <int> cmp;
    map <int,int> mp;
    ll a[m + 1], b[m + 1], c[m + 1], d[m + 1];
    for(int i = 1; i <= m; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        cmp.pb(a[i]);
        cmp.pb(b[i]);
        cmp.pb(c[i]);
    }
    cmp.pb(1);
    cmp.pb(n);
    sort(cmp.begin(), cmp.end());
    for(int i = 0; i < cmp.size(); i++){
        mp[cmp[i]] = i + 1;
    }
    for(int i = 1; i <= m; i++){
        a[i] = mp[a[i]];
        b[i] = mp[b[i]];
        c[i] = mp[c[i]];
    }
    int last = mp[n], f = mp[1];
    for(int i = 1; i <= last; i++)
        update(1, 1, last, i, linf);
    update(1, 1, last, f, 0);
    ll DP[m + 1], dp[m + 1];
    fill(DP + 1, DP + m + 1, linf);
    fill(dp + 1, dp + m + 1, linf);
    for(int i = 1; i <= m; i++){
        ll v = get(1, 1, last, a[i], b[i]);
        dp[i] = v + d[i];
        dp[i] = min(dp[i], linf);
        ll u = get(1, 1, last, c[i], c[i]);
        if(u > dp[i])update(1, 1, last,  c[i], dp[i]);
    }
    for(int i = 1; i <= last; i++)
        update(1, 1, last, i, linf);
    update(1, 1, last, last, 0);
    for(int i = 1; i <= m; i++){
        ll v = get(1, 1, last, a[i], b[i]);
        DP[i] = v + d[i];
        DP[i] = min(DP[i], linf);
        ll u = get(1, 1, last, c[i], c[i]);
        if(u > DP[i])update(1, 1,  last, c[i], DP[i]);
    }
    ll ans = linf;
    for(int i = 1; i <= m; i++){
        ans = min(ans, dp[i] + DP[i] - d[i]);
    }
    for(int i = 1; i <= m; i++){
        if(dp[i] == linf) dp[i] = -1;
        if(DP[i] == linf) DP[i] = -1;
        //cout << dp[i] << ' ' << DP[i] << "\n";
    }
    if(ans == linf)
        cout << -1;
    else cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
pinball.cpp: In function 'int main()':
pinball.cpp:56:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int i = 0; i < cmp.size(); i++){
      |                    ~~^~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |