답안 #67168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67168 2018-08-13T12:54:30 Z imeimi2000 Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
1324 ms 7756 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
llong d[500001];

int getPos(int i, int t) {
    return i - t / d[i] * d[i];
}

int lowbound(int x, int t) {
    int s = 0, e = n + 1;
    while (s < e) {
        int m = (s + e) / 2;
        if (getPos(m, t) < x) s = m + 1;
        else e = m;
    }
    return s;
}

int main() {

	int q;
	scanf("%d%d", &n, &q);
	d[0] = 1;
	for (int i = 1; i <= n; ++i) {
        scanf("%lld", d + i);
        d[i] = ((d[i] - 1) / d[i - 1] + 1) * d[i - 1];
	}

	while (q--) {
        int t, l, r;
        scanf("%d%d%d", &t, &l, &r);
        printf("%d\n", lowbound(-l + 1, t) - lowbound(-r, t));
	}
	return 0;
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:41: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:44:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", d + i);
         ~~~~~^~~~~~~~~~~~~~~
worst_reporter3.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &t, &l, &r);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1273 ms 7252 KB Output is correct
2 Correct 1186 ms 7484 KB Output is correct
3 Correct 1186 ms 7484 KB Output is correct
4 Correct 1219 ms 7484 KB Output is correct
5 Correct 1174 ms 7484 KB Output is correct
6 Correct 1198 ms 7520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7520 KB Output is correct
2 Correct 3 ms 7520 KB Output is correct
3 Correct 4 ms 7520 KB Output is correct
4 Correct 4 ms 7520 KB Output is correct
5 Correct 5 ms 7520 KB Output is correct
6 Correct 3 ms 7520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1273 ms 7252 KB Output is correct
2 Correct 1186 ms 7484 KB Output is correct
3 Correct 1186 ms 7484 KB Output is correct
4 Correct 1219 ms 7484 KB Output is correct
5 Correct 1174 ms 7484 KB Output is correct
6 Correct 1198 ms 7520 KB Output is correct
7 Correct 4 ms 7520 KB Output is correct
8 Correct 3 ms 7520 KB Output is correct
9 Correct 4 ms 7520 KB Output is correct
10 Correct 4 ms 7520 KB Output is correct
11 Correct 5 ms 7520 KB Output is correct
12 Correct 3 ms 7520 KB Output is correct
13 Correct 783 ms 7520 KB Output is correct
14 Correct 813 ms 7520 KB Output is correct
15 Correct 819 ms 7520 KB Output is correct
16 Correct 718 ms 7520 KB Output is correct
17 Correct 940 ms 7520 KB Output is correct
18 Correct 891 ms 7520 KB Output is correct
19 Correct 942 ms 7520 KB Output is correct
20 Correct 936 ms 7520 KB Output is correct
21 Correct 883 ms 7520 KB Output is correct
22 Correct 1047 ms 7520 KB Output is correct
23 Correct 915 ms 7520 KB Output is correct
24 Correct 918 ms 7520 KB Output is correct
25 Correct 1172 ms 7624 KB Output is correct
26 Correct 1324 ms 7756 KB Output is correct
27 Correct 1094 ms 7756 KB Output is correct
28 Correct 1124 ms 7756 KB Output is correct
29 Correct 1010 ms 7756 KB Output is correct
30 Correct 1145 ms 7756 KB Output is correct
31 Correct 957 ms 7756 KB Output is correct
32 Correct 863 ms 7756 KB Output is correct
33 Correct 3 ms 7756 KB Output is correct