Submission #1234941

#TimeUsernameProblemLanguageResultExecution timeMemory
1234941BahaminWorst Reporter 3 (JOI18_worst_reporter3)C++20
12 / 100
2084 ms4340 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; 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); // cout << i << " " << x[i] << endl; } while (q--) { int l, r, t; cin >> t >> l >> r; int ans = (l <= t && t <= r ? 1 : 0); for (int i = 1; i <= n; i++) { int ind = (t / x[i]) * x[i] - i; // cout << i << " " << ind << endl; if (l <= ind && ind <= r) ans++; } 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...