답안 #171812

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171812 2019-12-30T12:45:58 Z mhy908 Worst Reporter 3 (JOI18_worst_reporter3) C++14
0 / 100
979 ms 23116 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1000000007;
int n, q;
LL d[500010];
LL findx(int num, LL t){
    if(num==0)return t;
    return t/d[num]*d[num]-(LL)num;
}
int f(int st, int fin, LL x, LL t){
    if(st==fin)return st;
    int mid=(st+fin)/2+1;
    LL xx=findx(mid, t);
    if(xx<x)return f(st, mid-1, x, t);
    return f(mid, fin, x, t);
}
int g(int st, int fin, LL x, LL t){
    if(st==fin)return st;
    int mid=(st+fin)/2;
    LL xx=findx(mid, t);
    if(xx>x)return g(mid+1, fin, x, t);
    return g(st, mid, x, t);
}
int main()
{
    scanf("%d %d", &n, &q);
    for(int i=1; i<=n; i++){
        scanf("%lld", &d[i]);
        if(i>1){
            if(d[i]<d[i-1])d[i]=d[i-1];
            d[i]=(d[i]+1)/d[i-1]*d[i-1];
        }
    }
    for(int i=1; i<=q; i++){
        LL a, b, c;
        scanf("%lld %lld %lld", &a, &b, &c);
        int ff=f(0, n, b, a);
        int gg=g(0, n, c, a);
        if(a<b)ff=-1;
        if(findx(n, a)>c)gg=n+1;
        printf("%d\n", ff-gg+1);
    }
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:27: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("%lld", &d[i]);
         ~~~~~^~~~~~~~~~~~~~~
worst_reporter3.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld", &a, &b, &c);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 979 ms 23116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 979 ms 23116 KB Output isn't correct
2 Halted 0 ms 0 KB -