답안 #44370

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44370 2018-04-01T06:21:02 Z RayaBurong25_1 Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
944 ms 9516 KB
#include <stdio.h>
#include <algorithm>
int D[500005];
int E[500005];
int T;
typedef struct node node;
struct node
{
    int i;
};
node V[500005];
int comp1(node element, int value)
{
    return (T/E[element.i]*E[element.i] - element.i) < value;
}
int comp2(int value, node element)
{
    return (T/E[element.i]*E[element.i] - element.i) > value;
}
int main()
{
    int N, Q;
    scanf("%d %d", &N, &Q);
    int i;
    D[0] = 1;
    E[0] = 1;
    for (i = 1; i <= N; i++)
    {
        scanf("%d", &D[i]);
        E[i] = ((D[i] - 1)/E[i - 1] + 1)*E[i - 1];
        // printf("E%d\n", E[i]);
    }
    for (i = 0; i <= N; i++)
        V[i].i = N - i;
    int L, R;
    int l, r;
    int j;
    for (i = 0; i < Q; i++)
    {
        scanf("%d %d %d", &T, &L, &R);
        l = std::lower_bound(&V[0], &V[N + 1], L, comp1) - &V[0];
        r = std::upper_bound(&V[0], &V[N + 1], R, comp2) - &V[0];
        // for (j = 0; j <= N; j++)
            // printf("#%d\n", T/E[j]*E[j] - j);
        // printf("l%d r%d\n", l, r);
        printf("%d\n", r - l);
    }
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:37:9: warning: unused variable 'j' [-Wunused-variable]
     int j;
         ^
worst_reporter3.cpp:23:10: 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:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &D[i]);
         ~~~~~^~~~~~~~~~~~~
worst_reporter3.cpp:40: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 928 ms 9260 KB Output is correct
2 Correct 861 ms 9260 KB Output is correct
3 Correct 904 ms 9460 KB Output is correct
4 Correct 900 ms 9460 KB Output is correct
5 Correct 903 ms 9460 KB Output is correct
6 Correct 917 ms 9460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 9460 KB Output is correct
2 Correct 2 ms 9460 KB Output is correct
3 Correct 2 ms 9460 KB Output is correct
4 Correct 2 ms 9460 KB Output is correct
5 Correct 3 ms 9460 KB Output is correct
6 Correct 3 ms 9460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 928 ms 9260 KB Output is correct
2 Correct 861 ms 9260 KB Output is correct
3 Correct 904 ms 9460 KB Output is correct
4 Correct 900 ms 9460 KB Output is correct
5 Correct 903 ms 9460 KB Output is correct
6 Correct 917 ms 9460 KB Output is correct
7 Correct 3 ms 9460 KB Output is correct
8 Correct 2 ms 9460 KB Output is correct
9 Correct 2 ms 9460 KB Output is correct
10 Correct 2 ms 9460 KB Output is correct
11 Correct 3 ms 9460 KB Output is correct
12 Correct 3 ms 9460 KB Output is correct
13 Correct 540 ms 9460 KB Output is correct
14 Correct 566 ms 9460 KB Output is correct
15 Correct 520 ms 9460 KB Output is correct
16 Correct 523 ms 9460 KB Output is correct
17 Correct 701 ms 9460 KB Output is correct
18 Correct 680 ms 9460 KB Output is correct
19 Correct 679 ms 9460 KB Output is correct
20 Correct 782 ms 9460 KB Output is correct
21 Correct 716 ms 9460 KB Output is correct
22 Correct 685 ms 9460 KB Output is correct
23 Correct 788 ms 9460 KB Output is correct
24 Correct 698 ms 9460 KB Output is correct
25 Correct 944 ms 9516 KB Output is correct
26 Correct 935 ms 9516 KB Output is correct
27 Correct 729 ms 9516 KB Output is correct
28 Correct 718 ms 9516 KB Output is correct
29 Correct 724 ms 9516 KB Output is correct
30 Correct 776 ms 9516 KB Output is correct
31 Correct 746 ms 9516 KB Output is correct
32 Correct 703 ms 9516 KB Output is correct
33 Correct 2 ms 9516 KB Output is correct