# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
917143 | 2024-01-27T09:54:15 Z | alexdd | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 2000 ms | 8744 KB |
#include<bits/stdc++.h> using namespace std; /*ifstream fin("input.in"); ofstream fout("output.out"); #define cin fin #define cout fout*/ #define int long long int n,q; int d[500005]; int p[500005]; bool ismare[500005]; int calc_cur(int i, int ult) { return -i + ((ult + i - 1)/p[i]) * p[i]; } void calc_p() { int mxm=d[1]; p[1]=d[1]; ismare[1]=1; for(int i=2;i<=n;i++) { if(d[i]>=mxm) { mxm=((d[i]-1)/mxm + 1)*mxm; p[i]=mxm; ismare[i]=1; } else { ismare[i]=0; } } } signed main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>q; for(int i=1;i<=n;i++) cin>>d[i]; calc_p(); int le,ri,t; while(q--) { cin>>t>>le>>ri; int cnt=0,mxm=0,ult=t; if(le<=t && t<=ri) cnt++; for(int i=1;i<=n;i++) { int cur; if(ismare[i]) { cur=calc_cur(i,t-(i-1)); } else { cur=ult-1; } ult=cur; if(cur<le) break; if(cur<=ri) cnt++; } cout<<cnt<<"\n"; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2028 ms | 8744 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 2 ms | 4444 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 2 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2028 ms | 8744 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |