Submission #604657

# Submission time Handle Problem Language Result Execution time Memory
604657 2022-07-25T08:29:03 Z alireza_kaviani Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
406 ms 23336 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)      (x).begin(),(x).end()
#define X           first
#define Y           second
#define sep         ' '
#define endl        '\n'
#define SZ(x)       ll(x.size())

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; //998244353; //1e9 + 9;

int n , q , D[MAXN];
vector<int> vec;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    cin >> n >> q; D[0] = 1;
    for(int i = 1 ; i <= n ; i++){
        cin >> D[i];
    }
    vec.push_back(0);
    for(int i = 1 ; i <= n ; i++){
        D[i] = (D[i] + D[i - 1] - 1) / D[i - 1] * D[i - 1];
        if(D[i] != D[vec.back()]){
            vec.push_back(i);
        }
        if(D[i] > MOD)  break;
    }
    vec.push_back(n + 1);

    while(q--){
        int t , l , r , ans = 0;
        cin >> t >> l >> r;
        for(int i = 0 ; i + 1 < SZ(vec) ; i++){
            int T = t / D[vec[i]];
            int L = T * D[vec[i]] - vec[i + 1] + 1 , R = T * D[vec[i]] - vec[i];
            L = max(L , l); R = min(R , r);
            ans += max(0 , R - L + 1);
        }
        cout << ans << endl;
    }

    return 0;
}
/*

*/
# Verdict Execution time Memory Grader output
1 Correct 261 ms 20624 KB Output is correct
2 Correct 251 ms 20684 KB Output is correct
3 Correct 236 ms 20676 KB Output is correct
4 Correct 269 ms 20644 KB Output is correct
5 Correct 275 ms 20704 KB Output is correct
6 Correct 291 ms 20608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 261 ms 20624 KB Output is correct
2 Correct 251 ms 20684 KB Output is correct
3 Correct 236 ms 20676 KB Output is correct
4 Correct 269 ms 20644 KB Output is correct
5 Correct 275 ms 20704 KB Output is correct
6 Correct 291 ms 20608 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 241 ms 19132 KB Output is correct
14 Correct 233 ms 19788 KB Output is correct
15 Correct 249 ms 18436 KB Output is correct
16 Correct 236 ms 18972 KB Output is correct
17 Correct 341 ms 23192 KB Output is correct
18 Correct 326 ms 23204 KB Output is correct
19 Correct 397 ms 23240 KB Output is correct
20 Correct 336 ms 23220 KB Output is correct
21 Correct 328 ms 23336 KB Output is correct
22 Correct 406 ms 23332 KB Output is correct
23 Correct 353 ms 23116 KB Output is correct
24 Correct 334 ms 23268 KB Output is correct
25 Correct 269 ms 20704 KB Output is correct
26 Correct 281 ms 20728 KB Output is correct
27 Correct 324 ms 22912 KB Output is correct
28 Correct 397 ms 23084 KB Output is correct
29 Correct 393 ms 22680 KB Output is correct
30 Correct 343 ms 22880 KB Output is correct
31 Correct 347 ms 23076 KB Output is correct
32 Correct 230 ms 19324 KB Output is correct
33 Correct 1 ms 212 KB Output is correct