Submission #1131104

#TimeUsernameProblemLanguageResultExecution timeMemory
113110412345678Escape Route 2 (JOI24_escape2)C++20
23 / 100
91 ms8016 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int nx=1e5+5; ll n, t, m, dp[nx], dp2[nx], a[nx], b[nx], q, l, r; ll cost(ll x, ll y) { if (x<=y) return y-x; return t-(x-y); } int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>t; for (int i=2; i<=n; i++) { cin>>m>>a[i]>>b[i]; } for (int i=2; i<=n; i++) { dp[i]=dp2[i-1]+b[i]-a[i]; if (i!=n) dp2[i]=dp[i]+cost(b[i], a[i+1]); } cin>>q; while (q--) { cin>>l>>r; cout<<dp[r]-dp2[l]<<'\n'; } } /* 6 10000 1 100 300 1 400 700 1 500 600 1 300 900 1 200 800 3 1 6 1 2 5 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...