Submission #243594

#TimeUsernameProblemLanguageResultExecution timeMemory
243594osaaateiasavtnlWorst Reporter 3 (JOI18_worst_reporter3)C++14
12 / 100
2071 ms4584 KiB
#include<bits/stdc++.h>     
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n, q;
    cin >> n >> q;
    vector <int> d(n);
    for (int i = 0; i < n; ++i)
        cin >> d[i];

    while (q--) {
        int t, l, r;
        cin >> t >> l >> r;

        int ans = 0;
        ans += l <= t && t <= r;

        int step = 1, cnt = t;
        for (int i = 0; i < n; ++i) {
            if (d[i] <= step) {
                int to = -i-1+cnt*step;
                ans += l <= to && to <= r;
            }   
            else {
                int x = (d[i]+step-1)/step;
                int step1 = step * x;
                int cnt1 = cnt/x;
                int to = -i-1 + cnt1 * step1;
                ans += l <= to && to <= r;
                tie(step, cnt) = mp(step1, cnt1);
            }
        }   
        cout << ans << endl;
    }   

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...