Submission #764210

# Submission time Handle Problem Language Result Execution time Memory
764210 2023-06-23T08:38:52 Z minhcool Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
324 ms 25308 KB
#define local
#ifndef local
#include ""
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 6e5 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

mt19937 rng(1);

int rnd(int l, int r){
	int temp = rng() % (r - l + 1);
	return abs(temp) + l;
}

int n, q, d[N];

vector<pair<int, ii>> v;// cycle, le, ri

#ifdef local
void process(){
    cin >> n >> q;
    for(int i = 1; i <= n; i++) cin >> d[i];
    int lst = d[1], lst2 = 1;
    v.pb({1, {0, 0}});
    for(int i = 2; i <= n; i++){
        if(d[i] > lst){
            v.pb({lst, {lst2, i - 1}});
            int temp = (d[i] + lst - 1) / lst;
            lst *= temp;
            lst2 = i;
        }
    }
    v.pb({lst, {lst2, n}});
    //cin >> q;
    while(q--){
        int t, l, r;
        cin >> t >> l >> r;
       // t--;
        int answer = 0;
        for(auto it : v){
            int temp = (t / it.fi) * it.fi;
            ii b = {-it.se.fi, -it.se.se};
            b.fi += temp, b.se += temp;
            swap(b.fi, b.se);
          //  cout << b.fi << " " << b.se << "\n";
            answer += max(0LL, min(r, b.se) - max(l, b.fi) + 1);
        }
        cout << answer << "\n";
    }
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	process();
}
#endif
# Verdict Execution time Memory Grader output
1 Correct 200 ms 22716 KB Output is correct
2 Correct 189 ms 22644 KB Output is correct
3 Correct 197 ms 22648 KB Output is correct
4 Correct 178 ms 22696 KB Output is correct
5 Correct 265 ms 22604 KB Output is correct
6 Correct 179 ms 22648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 200 ms 22716 KB Output is correct
2 Correct 189 ms 22644 KB Output is correct
3 Correct 197 ms 22648 KB Output is correct
4 Correct 178 ms 22696 KB Output is correct
5 Correct 265 ms 22604 KB Output is correct
6 Correct 179 ms 22648 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 292 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 235 ms 21128 KB Output is correct
14 Correct 249 ms 21688 KB Output is correct
15 Correct 224 ms 20376 KB Output is correct
16 Correct 184 ms 20964 KB Output is correct
17 Correct 253 ms 25260 KB Output is correct
18 Correct 256 ms 25232 KB Output is correct
19 Correct 267 ms 25280 KB Output is correct
20 Correct 249 ms 25196 KB Output is correct
21 Correct 248 ms 25204 KB Output is correct
22 Correct 241 ms 25308 KB Output is correct
23 Correct 247 ms 25156 KB Output is correct
24 Correct 280 ms 25272 KB Output is correct
25 Correct 209 ms 22712 KB Output is correct
26 Correct 221 ms 22632 KB Output is correct
27 Correct 248 ms 24772 KB Output is correct
28 Correct 324 ms 25088 KB Output is correct
29 Correct 320 ms 24612 KB Output is correct
30 Correct 282 ms 24776 KB Output is correct
31 Correct 308 ms 25064 KB Output is correct
32 Correct 187 ms 21296 KB Output is correct
33 Correct 1 ms 212 KB Output is correct