# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
69767 | 2018-08-21T13:11:31 Z | yogahmad | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 1234 ms | 263168 KB |
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fbo find_by_order #define ook order_of_key #define f first #define s second #define pb push_back #define reset(a,b) memset(a,b,sizeof a); #define MOD 1000000007 #define MID (l+r)/2 #define ALL(x) x.begin(),x.end() #define debug(x) cout<<#x<<" = "<<(x)<<endl #define mx 500003 #define pc(x) putchar_unlocked(x); typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds; long long n,a[mx],gerak[mx],setiap[mx],q,t,l,r; long long cel(long long a,long long b){ long long ret=a/b; if(a%b)ret++; return ret; } int main(){ scanf("%d%d",&n,&q); for(int i=1;i<=n;i++)scanf("%d",&a[i]); setiap[0]=gerak[0]=1; gerak[1]=a[1]; setiap[1]=a[1]; for(int i=2;i<=n;i++){ long long sem=cel(a[i],gerak[i-1]); setiap[i]=sem*setiap[i-1]; gerak[i]=sem*gerak[i-1]; } //for(int i=1;i<=n;i++)cout<<setiap[i]<<' '<<gerak[i]<<endl; while(q--){ scanf("%lld%lld%lld",&t,&l,&r); int lo=0,hi=n,kiri=-1; while(lo<=hi){ int mid=(lo+hi)>>1; long long brp=t/setiap[mid]; brp=brp*gerak[mid]; long long di=brp-mid; if(l<=di){ lo=mid+1; kiri=mid; } else hi=mid-1; } // debug(kiri); if(kiri==-1){ puts("0"); continue; } lo=0,hi=n; int kanan=-1; while(lo<=hi){ int mid=(lo+hi)>>1; long long brp=t/setiap[mid]; brp=brp*gerak[mid]; long long di=brp-mid; if(di<=r){ hi=mid-1; kanan=mid; } else lo=mid+1; } //debug(kanan); if(kanan==-1){ puts("0"); continue; } printf("%d\n",kiri-kanan+1); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1232 ms | 30632 KB | Output is correct |
2 | Correct | 1234 ms | 46308 KB | Output is correct |
3 | Correct | 1012 ms | 61616 KB | Output is correct |
4 | Correct | 1187 ms | 77108 KB | Output is correct |
5 | Correct | 1171 ms | 92580 KB | Output is correct |
6 | Correct | 1100 ms | 107984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 107984 KB | Output is correct |
2 | Correct | 4 ms | 107984 KB | Output is correct |
3 | Correct | 3 ms | 107984 KB | Output is correct |
4 | Correct | 4 ms | 107984 KB | Output is correct |
5 | Correct | 4 ms | 107984 KB | Output is correct |
6 | Correct | 3 ms | 107984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1232 ms | 30632 KB | Output is correct |
2 | Correct | 1234 ms | 46308 KB | Output is correct |
3 | Correct | 1012 ms | 61616 KB | Output is correct |
4 | Correct | 1187 ms | 77108 KB | Output is correct |
5 | Correct | 1171 ms | 92580 KB | Output is correct |
6 | Correct | 1100 ms | 107984 KB | Output is correct |
7 | Correct | 5 ms | 107984 KB | Output is correct |
8 | Correct | 4 ms | 107984 KB | Output is correct |
9 | Correct | 3 ms | 107984 KB | Output is correct |
10 | Correct | 4 ms | 107984 KB | Output is correct |
11 | Correct | 4 ms | 107984 KB | Output is correct |
12 | Correct | 3 ms | 107984 KB | Output is correct |
13 | Correct | 663 ms | 122184 KB | Output is correct |
14 | Correct | 663 ms | 138836 KB | Output is correct |
15 | Correct | 639 ms | 154068 KB | Output is correct |
16 | Correct | 711 ms | 169872 KB | Output is correct |
17 | Correct | 861 ms | 189764 KB | Output is correct |
18 | Correct | 857 ms | 208420 KB | Output is correct |
19 | Correct | 877 ms | 227160 KB | Output is correct |
20 | Correct | 807 ms | 245932 KB | Output is correct |
21 | Runtime error | 975 ms | 263168 KB | Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
22 | Halted | 0 ms | 0 KB | - |