Submission #171812

#TimeUsernameProblemLanguageResultExecution timeMemory
171812mhy908Worst Reporter 3 (JOI18_worst_reporter3)C++14
0 / 100
979 ms23116 KiB
#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 (stderr)

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);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...