# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
211010 | 2020-03-19T05:35:11 Z | DodgeBallMan | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 890 ms | 29464 KB |
#include <bits/stdc++.h> #define long long long using namespace std; const int N = 5e5 + 10; int n, q; long d[N], t[N]; long chk( long x, long ti ) { return ( ti/t[x] ) * t[x] - x; } int main() { scanf("%d %d",&n,&q); d[0] = 1, t[0] = 1; for( int i = 1 ; i <= n ; i++ ) scanf("%lld",&d[i]); //printf("\n"); for( int i = 1 ; i <= n ; i++ ) { long a = d[i] / t[i-1]; if( a*t[i-1] != d[i] ) a++; t[i] = t[i-1] * a; //printf("%lld\n",t[i]); } while( q-- ) { long ti, le, ri, lb, rb; scanf("%lld %lld %lld",&ti,&le,&ri); int l = 0, r = n; if( chk( 0, ti ) < le ) { printf("0\n"); continue ; } else if( chk( n, ti ) > ri ) { printf("0\n"); continue ; } while( l < r ) { long mid = ( long )( l + r >> 1 ); if( chk( mid, ti ) <= ri ) r = mid; else l = mid + 1; } rb = ( long )l, l = 0, r = n; while( l < r ) { long mid = ( long )( l + r + 1 >> 1 ); if( chk( mid, ti ) >= le ) l = mid; else r = mid - 1; } lb = ( long )l; //printf("%lld %lld\n",lb,rb); printf("%lld\n",lb-rb+1); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 872 ms | 26656 KB | Output is correct |
2 | Correct | 833 ms | 26684 KB | Output is correct |
3 | Correct | 874 ms | 26680 KB | Output is correct |
4 | Correct | 886 ms | 26720 KB | Output is correct |
5 | Correct | 845 ms | 26712 KB | Output is correct |
6 | Correct | 890 ms | 26612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 360 KB | Output is correct |
6 | Correct | 6 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 872 ms | 26656 KB | Output is correct |
2 | Correct | 833 ms | 26684 KB | Output is correct |
3 | Correct | 874 ms | 26680 KB | Output is correct |
4 | Correct | 886 ms | 26720 KB | Output is correct |
5 | Correct | 845 ms | 26712 KB | Output is correct |
6 | Correct | 890 ms | 26612 KB | Output is correct |
7 | Correct | 6 ms | 384 KB | Output is correct |
8 | Correct | 6 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 7 ms | 360 KB | Output is correct |
12 | Correct | 6 ms | 384 KB | Output is correct |
13 | Correct | 674 ms | 25144 KB | Output is correct |
14 | Correct | 621 ms | 25824 KB | Output is correct |
15 | Correct | 584 ms | 24364 KB | Output is correct |
16 | Correct | 544 ms | 24952 KB | Output is correct |
17 | Correct | 706 ms | 29176 KB | Output is correct |
18 | Correct | 701 ms | 29168 KB | Output is correct |
19 | Correct | 863 ms | 29464 KB | Output is correct |
20 | Correct | 738 ms | 29180 KB | Output is correct |
21 | Correct | 814 ms | 29296 KB | Output is correct |
22 | Correct | 779 ms | 29372 KB | Output is correct |
23 | Correct | 785 ms | 29176 KB | Output is correct |
24 | Correct | 709 ms | 29408 KB | Output is correct |
25 | Correct | 869 ms | 26692 KB | Output is correct |
26 | Correct | 879 ms | 26744 KB | Output is correct |
27 | Correct | 791 ms | 28796 KB | Output is correct |
28 | Correct | 727 ms | 29048 KB | Output is correct |
29 | Correct | 664 ms | 28580 KB | Output is correct |
30 | Correct | 719 ms | 28820 KB | Output is correct |
31 | Correct | 710 ms | 28956 KB | Output is correct |
32 | Correct | 648 ms | 25212 KB | Output is correct |
33 | Correct | 5 ms | 384 KB | Output is correct |