Submission #627062

# Submission time Handle Problem Language Result Execution time Memory
627062 2022-08-12T06:19:09 Z pooyashams Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
625 ms 29176 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#define endl '\n'
#define X first
#define Y second

using namespace std;
typedef long long ll;
#define int ll
typedef long double ld;
typedef pair<int, int> pii;

const int maxn = 5e5+10;

int D[maxn];
int T[maxn];

inline int get_at(int i, int t)
{
	return -i + ( (t/T[i]) * T[i] );
}

int n;

inline int bisect(int x, int t)
{
	int down = -1;
	int up = n+1;
	while(up-down > 1)
	{
		int mid = (up+down) / 2;
		if(get_at(mid, t) <= x)
			up = mid;
		else
			down = mid;
	}
	return up;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int q; cin >> n >> q;
	for(int i = 1; i <= n; i++)
		cin >> D[i];
	T[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		T[i] = ((D[i] + T[i-1] - 1) / T[i-1]) * T[i-1];
	}
	while(q--)
	{
		int t, l, r; cin >> t >> l >> r;
		int a = bisect(r, t);
		int b = bisect(l-1, t);
		cout << b-a << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 488 ms 11084 KB Output is correct
2 Correct 598 ms 11084 KB Output is correct
3 Correct 625 ms 11080 KB Output is correct
4 Correct 565 ms 11068 KB Output is correct
5 Correct 535 ms 11140 KB Output is correct
6 Correct 561 ms 11088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 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 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 488 ms 11084 KB Output is correct
2 Correct 598 ms 11084 KB Output is correct
3 Correct 625 ms 11080 KB Output is correct
4 Correct 565 ms 11068 KB Output is correct
5 Correct 535 ms 11140 KB Output is correct
6 Correct 561 ms 11088 KB Output is correct
7 Correct 1 ms 340 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 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 392 ms 20032 KB Output is correct
14 Correct 397 ms 25592 KB Output is correct
15 Correct 387 ms 24340 KB Output is correct
16 Correct 371 ms 24888 KB Output is correct
17 Correct 461 ms 29128 KB Output is correct
18 Correct 449 ms 29124 KB Output is correct
19 Correct 412 ms 29124 KB Output is correct
20 Correct 424 ms 29132 KB Output is correct
21 Correct 406 ms 29080 KB Output is correct
22 Correct 406 ms 29136 KB Output is correct
23 Correct 431 ms 29176 KB Output is correct
24 Correct 408 ms 29136 KB Output is correct
25 Correct 512 ms 26500 KB Output is correct
26 Correct 546 ms 26612 KB Output is correct
27 Correct 499 ms 28668 KB Output is correct
28 Correct 428 ms 29004 KB Output is correct
29 Correct 471 ms 28524 KB Output is correct
30 Correct 457 ms 28668 KB Output is correct
31 Correct 441 ms 28940 KB Output is correct
32 Correct 419 ms 25180 KB Output is correct
33 Correct 0 ms 212 KB Output is correct