Submission #342361

#TimeUsernameProblemLanguageResultExecution timeMemory
342361jovan_bWorst Reporter 3 (JOI18_worst_reporter3)C++17
7 / 100
269 ms18924 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back const ll INF = 1000000000; ll intersect(ll l, ll r, ll tl, ll tr){ return max(0LL, min(r, tr) - max(l, tl) + 1); } int main(){ ios_base::sync_with_stdio(false), cin.tie(0); cout.precision(10); cout << fixed; int n, m; cin >> n >> m; vector <pair <pair <int, int>, ll>> intervals; intervals.push_back({{0, 0}, 1}); ll pos = 1; for(int i=1; i<=n; i++){ int x; cin >> x; ll g = pos*((x+pos)/pos); if(pos == 1) g = x; g = min(g, INF); if(g == intervals.back().second){ pair <pair <int, int>, ll> v = intervals.back(); intervals.pop_back(); v.first.first = -i; intervals.push_back(v); } else{ pair <pair <int, int>, ll> v; v.first.first = v.first.second = -i; v.second = g; intervals.push_back(v); } pos = g; } /*for(auto c : intervals){ cout << c.first.first << " " << c.first.second << " " << c.second << "\n"; }*/ while(m--){ ll t, tl, tr; cin >> t >> tl >> tr; ll res = 0; for(auto c : intervals){ ll l = c.first.first; ll r = c.first.second; ll g = c.second; ll dist = g*(t/g); l += dist; r += dist; res += intersect(l, r, tl, tr); } cout << res << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...