제출 #1299276

#제출 시각아이디문제언어결과실행 시간메모리
1299276StefanSebezWorst Reporter 3 (JOI18_worst_reporter3)C++20
100 / 100
248 ms11376 KiB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
const int N=5e5+50;
int n,q;ll D[N];
int main(){
    scanf("%i%i",&n,&q);
    for(int i=1;i<=n;i++)scanf("%lld",&D[i]);
    ll s[n+10];s[0]=1;
    vector<pair<ll,ll>>itv;
    for(int i=1;i<=n;i++) s[i]=(D[i]+s[i-1]-1)/s[i-1]*s[i-1];
    for(int i=1;i<=n;){
        int j=i;
        while(j<=n&&s[i]==s[j])j++;
        itv.pb({i,j-1});
        i=j;
    }
    while(q--){
        ll t,l,r;scanf("%lld%lld%lld",&t,&l,&r);
        int res=0;
        for(auto [l1,r1]:itv){
            ll L=(t/s[r1])*s[r1]-r1,R=(t/s[l1])*s[l1]-l1;
            if(R<l||r<L) continue;
            L=max(L,l),R=min(R,r);
            res+=R-L+1;
        }
        if(l<=t&&t<=r)res++;
        printf("%i\n",res);
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%i%i",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~
worst_reporter3.cpp:13:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(int i=1;i<=n;i++)scanf("%lld",&D[i]);
      |                          ~~~~~^~~~~~~~~~~~~~
worst_reporter3.cpp:24:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         ll t,l,r;scanf("%lld%lld%lld",&t,&l,&r);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...