Submission #1234950

#TimeUsernameProblemLanguageResultExecution timeMemory
1234950BahaminWorst Reporter 3 (JOI18_worst_reporter3)C++20
100 / 100
165 ms7476 KiB
#include <bits/stdc++.h> using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; } #define ll long long #define ld long double #define all(a) (a).begin(), (a).end() #define sui cout.tie(NULL); cin.tie(NULL); ios_base::sync_with_stdio(false) const int MAX_N = 1e5 + 5; const int MOD = 1e9 + 7; const ll INF = 1e9; const ld EPS = 1e-9; const int LOG = 30; void solve() { int n, q; cin >> n >> q; ll x[n + 1]; x[0] = 1; vector<pair<int, pair<int, int>>> vs; vs.push_back(make_pair(1, make_pair(0, 0))); for (int i = 1; i <= n; i++) { int num; cin >> num; x[i] = x[i - 1] * ((num + x[i - 1] - 1) / x[i - 1]); x[i] = min(x[i], (ll) MOD); if (x[i] == x[i - 1]) vs.back().second.second = i; else vs.push_back(make_pair(x[i], make_pair(i, i))); } while (q--) { int l, r, t; cin >> t >> l >> r; int ans = 0; for (auto x : vs) { int num = (t / x.first) * x.first; int l1 = max(l, num - x.second.second); int r1 = min(r, num - x.second.first); ans += max(0, r1 - l1 + 1); } cout << ans << "\n"; } } int main() { sui; int tc = 1; //cin >> tc; for (int t = 1; t <= tc; t++) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...