Submission #429563

# Submission time Handle Problem Language Result Execution time Memory
429563 2021-06-16T06:45:47 Z Kevin_Zhang_TW Worst Reporter 3 (JOI18_worst_reporter3) C++17
12 / 100
2000 ms 8120 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
// My bug list :
// integer overflow
// 0based, 1based forgotten
// index out of bound
// n, m, i, j typo
// some cases are missing

const int MAX_N = 500010;

int n, q;

// per[i] means how many step last one move, then I move
int D[MAX_N], v[MAX_N], per[MAX_N], len[MAX_N];

void init() {
	v[0] = 1;
	for (int i = 1;i <= n;++i) {
		//per[i] = cdiv(D[i] - 1, v[i-1]);
		per[i] = (D[i]-1) / v[i-1] + 1;
		v[i] = per[i] * v[i-1];
	}
	for (int i = n;i >= 0;--i) {
		len[i] = 1;
		if (per[i+1] == 1) {
			len[i] = len[i+1] + 1;
		}
	}
	per[n+1] = 1;
}

int qry(int t, int l, int r) {
	int res = 0;
	for (int i = 0;i <= n;++i) {
		int at = -i + t * v[i];
		if (at <= r && at >= l) ++res;
		t /= per[i+1];
	}
	return res;
}

int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> q;
	for (int i = 1;i <= n;++i)
		cin >> D[i];

	init();

	while (q--) {
		int t, l, r;
		cin >> t >> l >> r;
		cout << qry(t, l, r) << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2062 ms 8120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 7 ms 332 KB Output is correct
3 Correct 7 ms 332 KB Output is correct
4 Correct 6 ms 332 KB Output is correct
5 Correct 7 ms 332 KB Output is correct
6 Correct 6 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2062 ms 8120 KB Time limit exceeded
2 Halted 0 ms 0 KB -