Submission #62919

# Submission time Handle Problem Language Result Execution time Memory
62919 2018-07-30T20:30:29 Z kingpig9 Worst Reporter 3 (JOI18_worst_reporter3) C++11
100 / 100
1458 ms 13728 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 5e5 + 10;
const ll INF = 2e9;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

int N, Q;
ll P[MAXN];

int moo (ll t, ll x) {
	int lo = 0, hi = N + 2;	//how many are >= x?
	while (hi - lo > 1) {
		int mid = (lo + hi) / 2;
		if (P[mid - 1] * (t / P[mid - 1]) - (mid - 1) >= x) {
			lo = mid;
		} else {
			hi = mid;
		}
	}
	return lo;
}

int main() {
	scanf("%d %d", &N, &Q);
	P[0] = 1;
	for (int i = 1; i <= N; i++) {
		ll d;
		scanf("%lld", &d);
		P[i] = ((d + P[i - 1] - 1) / P[i - 1]) * P[i - 1];
	}

	for (int qi = 0; qi < Q; qi++) {
		ll t, lt, rt;
		scanf("%lld %lld %lld", &t, &lt, &rt);
		printf("%d\n", moo(t, lt) - moo(t, rt + 1));
	}
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &Q);
  ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &d);
   ~~~~~^~~~~~~~~~~~
worst_reporter3.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld", &t, &lt, &rt);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1451 ms 13252 KB Output is correct
2 Correct 1255 ms 13332 KB Output is correct
3 Correct 1183 ms 13332 KB Output is correct
4 Correct 1307 ms 13524 KB Output is correct
5 Correct 1349 ms 13524 KB Output is correct
6 Correct 1458 ms 13624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 13624 KB Output is correct
2 Correct 3 ms 13624 KB Output is correct
3 Correct 4 ms 13624 KB Output is correct
4 Correct 4 ms 13624 KB Output is correct
5 Correct 4 ms 13624 KB Output is correct
6 Correct 4 ms 13624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1451 ms 13252 KB Output is correct
2 Correct 1255 ms 13332 KB Output is correct
3 Correct 1183 ms 13332 KB Output is correct
4 Correct 1307 ms 13524 KB Output is correct
5 Correct 1349 ms 13524 KB Output is correct
6 Correct 1458 ms 13624 KB Output is correct
7 Correct 4 ms 13624 KB Output is correct
8 Correct 3 ms 13624 KB Output is correct
9 Correct 4 ms 13624 KB Output is correct
10 Correct 4 ms 13624 KB Output is correct
11 Correct 4 ms 13624 KB Output is correct
12 Correct 4 ms 13624 KB Output is correct
13 Correct 917 ms 13624 KB Output is correct
14 Correct 836 ms 13624 KB Output is correct
15 Correct 809 ms 13624 KB Output is correct
16 Correct 850 ms 13624 KB Output is correct
17 Correct 1080 ms 13624 KB Output is correct
18 Correct 1067 ms 13624 KB Output is correct
19 Correct 1164 ms 13624 KB Output is correct
20 Correct 1041 ms 13624 KB Output is correct
21 Correct 1199 ms 13624 KB Output is correct
22 Correct 1037 ms 13624 KB Output is correct
23 Correct 1059 ms 13624 KB Output is correct
24 Correct 1108 ms 13624 KB Output is correct
25 Correct 1297 ms 13656 KB Output is correct
26 Correct 1212 ms 13728 KB Output is correct
27 Correct 1041 ms 13728 KB Output is correct
28 Correct 1044 ms 13728 KB Output is correct
29 Correct 1112 ms 13728 KB Output is correct
30 Correct 1054 ms 13728 KB Output is correct
31 Correct 1014 ms 13728 KB Output is correct
32 Correct 977 ms 13728 KB Output is correct
33 Correct 3 ms 13728 KB Output is correct