답안 #47019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47019 2018-04-26T11:53:37 Z vanogam Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
1915 ms 262144 KB
#include<bits/stdc++.h>
#pragma GCC optimize ("O3")
using namespace std;
long long a,s,d[500005],f,g,h,j,k,l,i,n,m;
long long pos(long long idx){
    if(d[idx]==0) return 0;
    return -idx+h/d[idx]*d[idx];
}
main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    d[0]=1;
    for(i=1;i<=n;i++){
        cin>>a;
        if(d[i-1]==0) return 0;
        d[i]=((a+d[i-1]-1)/d[i-1])*d[i-1];
        //cout<<"*"<<d[i]<<endl;
    }


    for(i=0;i<m;i++){
        cin>>h>>a>>s;
        long long l=-1,r=n+1,p1,p2;

        while(r-l>1){
            long long k=(l+r)/2;
            //cout<<"*"<<k<<" "<<h<<" "<<pos(k)<<endl;cout<<"#";
            if(pos(k)<a) {r=k;} else l=k;
        }
        p1=l;
        //if(p1!=-1 && pos(p1)>=a) p1++;
        l=-1;r=n+1;
        while(r-l>1){
            long long k=(l+r)/2;//cout<<"   *"<<k<<" "<<h<<" "<<pos(k)<<endl;
            if(pos(k)<=s) {r=k;} else l=k;
        }
        p2=l;
        //cout<<pos(p2)<<" "<<p2;
        //if(p2!=-1 && pos(p2)>=a) p2++;
        cout<<p1-p2<<endl;
    }
}

Compilation message

worst_reporter3.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1729 ms 7368 KB Output is correct
2 Correct 1729 ms 7436 KB Output is correct
3 Correct 1730 ms 7572 KB Output is correct
4 Correct 1793 ms 7572 KB Output is correct
5 Correct 1724 ms 7572 KB Output is correct
6 Correct 1681 ms 7572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7572 KB Output is correct
2 Correct 4 ms 7572 KB Output is correct
3 Correct 4 ms 7572 KB Output is correct
4 Correct 4 ms 7572 KB Output is correct
5 Correct 4 ms 7572 KB Output is correct
6 Correct 9 ms 7572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1729 ms 7368 KB Output is correct
2 Correct 1729 ms 7436 KB Output is correct
3 Correct 1730 ms 7572 KB Output is correct
4 Correct 1793 ms 7572 KB Output is correct
5 Correct 1724 ms 7572 KB Output is correct
6 Correct 1681 ms 7572 KB Output is correct
7 Correct 5 ms 7572 KB Output is correct
8 Correct 4 ms 7572 KB Output is correct
9 Correct 4 ms 7572 KB Output is correct
10 Correct 4 ms 7572 KB Output is correct
11 Correct 4 ms 7572 KB Output is correct
12 Correct 9 ms 7572 KB Output is correct
13 Correct 1374 ms 21632 KB Output is correct
14 Correct 1334 ms 38276 KB Output is correct
15 Correct 1587 ms 53400 KB Output is correct
16 Correct 1345 ms 69356 KB Output is correct
17 Correct 1533 ms 89188 KB Output is correct
18 Correct 1541 ms 108028 KB Output is correct
19 Correct 1653 ms 126572 KB Output is correct
20 Correct 1683 ms 145264 KB Output is correct
21 Correct 1814 ms 163944 KB Output is correct
22 Correct 1533 ms 182532 KB Output is correct
23 Correct 1589 ms 201164 KB Output is correct
24 Correct 1685 ms 219692 KB Output is correct
25 Correct 1915 ms 235704 KB Output is correct
26 Correct 1903 ms 251308 KB Output is correct
27 Correct 1587 ms 262144 KB Output is correct
28 Correct 1569 ms 262144 KB Output is correct
29 Correct 1565 ms 262144 KB Output is correct
30 Correct 1694 ms 262144 KB Output is correct
31 Correct 1603 ms 262144 KB Output is correct
32 Correct 1492 ms 262144 KB Output is correct
33 Correct 2 ms 262144 KB Output is correct