Submission #1337601

#TimeUsernameProblemLanguageResultExecution timeMemory
1337601pomaksikWorst Reporter 3 (JOI18_worst_reporter3)C++20
12 / 100
2094 ms8264 KiB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
const int max_n = 5e5;
int gain_pol[max_n + 7];
int slownes[max_n + 7];
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n , q;
    cin >> n >> q;
    for(int i = 1; i <= n; i++)
    {
        cin >> slownes[i];
    }
    gain_pol[1] = slownes[1];
    for(int i = 2; i <= n; i++)
    {
        gain_pol[i] = (slownes[i] + gain_pol[i - 1] - 1) / gain_pol[i - 1] * gain_pol[i - 1];
    }
    //for(int i = 1; i <= n; ++i)cout << co_ile[i] << ' ' << gain_pol[i] << '\n';
    //return 0;
    while(q--)
    {
        int t , l , r;
        cin >> t >> l >> r;
        int ans = 0;
        for(int i = 1; i <= n; i++)
        {
            int place = (t / gain_pol[i]) * gain_pol[i] - i;
            if(l <= place && place <= r)ans++;
        }
        if(l <= t && t <= r)ans++;
        cout << ans <<  '\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...