Submission #44368

# Submission time Handle Problem Language Result Execution time Memory
44368 2018-04-01T06:18:18 Z RayaBurong25_1 Worst Reporter 3 (JOI18_worst_reporter3) C++17
0 / 100
982 ms 9332 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]);
        if (i == 1)
            E[i] = D[i];
        else
            E[i] = (D[i]/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:40: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:43: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);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 982 ms 9332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 9332 KB Output is correct
2 Correct 2 ms 9332 KB Output is correct
3 Correct 3 ms 9332 KB Output is correct
4 Correct 2 ms 9332 KB Output is correct
5 Incorrect 3 ms 9332 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 982 ms 9332 KB Output isn't correct
2 Halted 0 ms 0 KB -