Submission #1041152

#TimeUsernameProblemLanguageResultExecution timeMemory
1041152aymanrsEscape Route 2 (JOI24_escape2)C++17
23 / 100
63 ms11860 KiB
#include<bits/stdc++.h> using namespace std; void solve(){ int n, t, r;cin >> n >> t; int a[n],b[n];for(int i = 0;i < n-1;i++){ cin >> r; cin >> a[i] >> b[i]; } long long g[n-1]; for(int i = 0;i < n-1;i++){ if(b[i] <= a[i+1]) g[i] = a[i+1]-a[i]; else g[i] = a[i+1]+t-a[i]; if(i) g[i] += g[i-1]; } int q;cin >> q; while(q--){ int l, r;cin >> l >> r;l--;r--; if(r==l+1) cout << b[l]-a[l] << '\n'; else { cout << g[r-2]-(l?g[l-1]:0) + b[r-1]-a[r-1] << '\n'; } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); solve(); }
#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...