답안 #916967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
916967 2024-01-26T21:11:31 Z alexdd Worst Reporter 3 (JOI18_worst_reporter3) C++17
0 / 100
2000 ms 8028 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,q;
int d[500005];
int p[500005];
int calc_cur(int i, int ult)
{
    int poz = -i;
    while(poz + p[i] < ult)
        poz += p[i];
    return poz;
    //return -i + ((ult + i - 1)/d[i]) * d[i];
}
void calc_p()
{
    int mxm=d[1];
    p[1]=d[1];
    for(int i=2;i<=n;i++)
    {
        if(d[i]>mxm)
        {
            mxm=d[i];
        }
        p[i]=mxm;
    }
}
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=1,ult=t;
        if(le<=t && t<=ri)
            cnt++;
        for(int i=1;i<=n;i++)
        {
            int cur;
            if(d[i]>mxm || 1)
            {
                cur=calc_cur(i,ult);
                mxm=d[i];
            }
            else
            {
                cur=ult-1;
            }
            ult=cur;
            if(le<=cur && cur<=ri)
                cnt++;
        }
        cout<<cnt<<"\n";
    }
    return 0;
}
/**

poz(t,i) = min(((x-i) - (x-i)%d[x])) pt x<=i

-9 -8 -7 -6 -5 -4 -3 -2 -1  0  1  2  3  4  5  6  7  8  9
 4  2     1  3     3        *

-9 -8 -7 -6 -5 -4 -3 -2 -1  0  1  2  3  4  5  6  7  8  9
             5  3  2  1  3  3  *

-9 -8 -7 -6 -5 -4 -3 -2 -1  0  1  2  3  4  5  6  7  8  9
             7           3  2  1  3  3  *


*/
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2039 ms 8028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2392 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Incorrect 3 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2039 ms 8028 KB Time limit exceeded
2 Halted 0 ms 0 KB -