# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125013 | 2019-07-04T11:06:33 Z | HassenAissa | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 1219 ms | 25424 KB |
#include <bits/stdc++.h> using namespace std; vector<int> posi; vector<int> tab; long long n; int main() { long long m,x,t,y; scanf("%lld%lld",&n,&m); //tab.push_back(1); posi.resize(n+1); for(long long i=0; i<n; i++) { scanf("%lld",&x); tab.push_back(x); } posi[0]=1; for(long long i=1; i<=n; i++) { if(posi[i-1]>=tab[i-1]) posi[i]=posi[i-1]; else posi[i]=posi[i-1]*((tab[i-1]+posi[i-1]-1)/posi[i-1]); } for(long long i=0; i<m; i++) { scanf("%lld%lld%lld",&t,&x,&y); bool cond=0; long long l=0,r=posi.size()-1; long long fir=0; long long sec=0; while(l<=r) { long long mid=(l+r)/2; long long p = posi[mid]*(t/posi[mid]) - mid; if(p>=x && p<=y) { r=mid-1; fir=mid; cond=true; } else if(p<x) { r=mid-1; } else { l=mid+1; } } if(cond==0) { cout << 0 << endl; continue; } l=fir; r=posi.size()-1; while(l<=r) { long long mid=(l+r)/2; long long p = posi[mid]*(t/posi[mid]) -mid; if(p>=x && p<=y) { l=mid+1; sec=mid; } else if(p<x) { r=mid-1; } else { l=mid+1; } } printf("%lld\n",sec-fir+1); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1054 ms | 22924 KB | Output is correct |
2 | Correct | 1073 ms | 23032 KB | Output is correct |
3 | Correct | 1085 ms | 22792 KB | Output is correct |
4 | Correct | 1053 ms | 22920 KB | Output is correct |
5 | Correct | 1043 ms | 23020 KB | Output is correct |
6 | Correct | 1056 ms | 22876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 4 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 4 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1054 ms | 22924 KB | Output is correct |
2 | Correct | 1073 ms | 23032 KB | Output is correct |
3 | Correct | 1085 ms | 22792 KB | Output is correct |
4 | Correct | 1053 ms | 22920 KB | Output is correct |
5 | Correct | 1043 ms | 23020 KB | Output is correct |
6 | Correct | 1056 ms | 22876 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
8 | Correct | 4 ms | 376 KB | Output is correct |
9 | Correct | 4 ms | 376 KB | Output is correct |
10 | Correct | 4 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 1077 ms | 21488 KB | Output is correct |
14 | Correct | 973 ms | 21904 KB | Output is correct |
15 | Correct | 1168 ms | 20616 KB | Output is correct |
16 | Correct | 1107 ms | 21136 KB | Output is correct |
17 | Correct | 990 ms | 23320 KB | Output is correct |
18 | Correct | 945 ms | 23528 KB | Output is correct |
19 | Correct | 951 ms | 22752 KB | Output is correct |
20 | Correct | 958 ms | 23476 KB | Output is correct |
21 | Correct | 950 ms | 23316 KB | Output is correct |
22 | Correct | 999 ms | 23304 KB | Output is correct |
23 | Correct | 956 ms | 23660 KB | Output is correct |
24 | Correct | 949 ms | 23288 KB | Output is correct |
25 | Correct | 1075 ms | 22776 KB | Output is correct |
26 | Correct | 1082 ms | 23016 KB | Output is correct |
27 | Correct | 1000 ms | 25044 KB | Output is correct |
28 | Correct | 1000 ms | 25424 KB | Output is correct |
29 | Correct | 990 ms | 24936 KB | Output is correct |
30 | Correct | 1025 ms | 25028 KB | Output is correct |
31 | Correct | 991 ms | 25232 KB | Output is correct |
32 | Correct | 1219 ms | 21400 KB | Output is correct |
33 | Correct | 2 ms | 256 KB | Output is correct |