Submission #100511

# Submission time Handle Problem Language Result Execution time Memory
100511 2019-03-11T22:09:42 Z rzbt Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
994 ms 29404 KB
#include <bits/stdc++.h>
#define MAXN 500005
using namespace std;
typedef long long ll;

ll n,q;
ll de[MAXN];
ll in[MAXN];

ll binarna(ll l,ll d,ll cilj,ll vreme,ll sol){
    if(l>d)return sol;
    ll mid=(l+d)/2;
    //printf("    %lld %lld",mid,in[mid]);
    if(vreme-(vreme%in[mid])-mid>=cilj)return binarna(mid+1,d,cilj,vreme,mid);
    else return binarna(l,mid-1,cilj,vreme,sol);
}

int main()
{
    scanf("%lld %lld", &n, &q);
    //freopen("lul.txt","w",stdout);
    for(ll i=1;i<=n;i++)
        scanf("%lld",de+i);

    in[1]=de[1];
    //printf("   %lld\n",in[1]);
    for(ll i=2;i<=n;i++){
        //printf("  %lld %lld\n",de[i],de[i-1]);
        if(in[i-1]>=5000000007ll){
            in[i]=5000000007ll;
            continue;
        }
        ll nak=(de[i]/in[i-1])+ (de[i]%in[i-1]?1:0);
        in[i]=nak*in[i-1];
        //printf("   %lld\n",in[i]);
    }
    while(q--){
        ll t,a,b;
        scanf("%lld %lld %lld", &t, &a, &b);
        ll tres=binarna(1,n,a,t,0)-binarna(1,n,b+1,t,0);
        if(t>=a && t<=b)tres++;
        printf("%lld\n",tres);

    }




    return 0;
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",de+i);
         ~~~~~^~~~~~~~~~~~~
worst_reporter3.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld", &t, &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 922 ms 12152 KB Output is correct
2 Correct 975 ms 12328 KB Output is correct
3 Correct 994 ms 12136 KB Output is correct
4 Correct 886 ms 12192 KB Output is correct
5 Correct 926 ms 12264 KB Output is correct
6 Correct 832 ms 12152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 922 ms 12152 KB Output is correct
2 Correct 975 ms 12328 KB Output is correct
3 Correct 994 ms 12136 KB Output is correct
4 Correct 886 ms 12192 KB Output is correct
5 Correct 926 ms 12264 KB Output is correct
6 Correct 832 ms 12152 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 542 ms 25232 KB Output is correct
14 Correct 607 ms 25848 KB Output is correct
15 Correct 516 ms 24440 KB Output is correct
16 Correct 525 ms 25008 KB Output is correct
17 Correct 779 ms 29180 KB Output is correct
18 Correct 765 ms 29176 KB Output is correct
19 Correct 680 ms 29252 KB Output is correct
20 Correct 815 ms 29224 KB Output is correct
21 Correct 786 ms 29212 KB Output is correct
22 Correct 781 ms 29176 KB Output is correct
23 Correct 685 ms 29184 KB Output is correct
24 Correct 789 ms 29404 KB Output is correct
25 Correct 986 ms 26748 KB Output is correct
26 Correct 941 ms 26724 KB Output is correct
27 Correct 820 ms 29048 KB Output is correct
28 Correct 690 ms 29132 KB Output is correct
29 Correct 703 ms 28852 KB Output is correct
30 Correct 805 ms 28824 KB Output is correct
31 Correct 812 ms 29144 KB Output is correct
32 Correct 713 ms 25208 KB Output is correct
33 Correct 2 ms 384 KB Output is correct