답안 #964062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964062 2024-04-16T09:12:43 Z 12345678 Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
282 ms 25404 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=5e5+5;

#define ll long long

ll n, q, d[nx], t, l, r, st, cur;
vector<pair<ll, ll>> v;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>q;
    d[0]=1;
    for (int i=1; i<=n; i++)
    {
        cin>>d[i];
        d[i]=d[i-1]*((d[i]-1)/d[i-1]+1);
    }
    st=1;
    for (int i=2; i<=n+1; i++) if (d[i]!=d[i-1]) v.push_back({st, i-1}), st=i;
    //for (auto [x, y]:v) cout<<"debug "<<x<<' '<<y<<'\n';
    while (q--)
    {
        cin>>t>>l>>r;
        ll res=(l<=t&&t<=r);
        cur=t;
        for (auto [x, y]:v)
        {
            ll m=(cur-(-x)-1)/d[y];
            //cout<<"move "<<x<<' '<<y<<' '<<m*d[y]<<'\n';
            ll a=-y+m*d[y], b=-x+m*d[y];
            //cout<<"here "<<a<<' '<<b<<'\n';
            if (b<l||r<a) res+=0;
            else if (l<=a&&b<=r) res+=b-a+1;
            else if (a<=l&&r<=b) res+=r-l+1;
            else res+=min(abs(r-a)+1, abs(l-b)+1);
            cur=-y+m*d[y];
        }
        cout<<res<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 166 ms 22748 KB Output is correct
2 Correct 179 ms 22744 KB Output is correct
3 Correct 193 ms 22728 KB Output is correct
4 Correct 171 ms 22764 KB Output is correct
5 Correct 184 ms 22644 KB Output is correct
6 Correct 170 ms 22632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 480 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 166 ms 22748 KB Output is correct
2 Correct 179 ms 22744 KB Output is correct
3 Correct 193 ms 22728 KB Output is correct
4 Correct 171 ms 22764 KB Output is correct
5 Correct 184 ms 22644 KB Output is correct
6 Correct 170 ms 22632 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 480 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 178 ms 21232 KB Output is correct
14 Correct 185 ms 21748 KB Output is correct
15 Correct 174 ms 20340 KB Output is correct
16 Correct 171 ms 20880 KB Output is correct
17 Correct 258 ms 25216 KB Output is correct
18 Correct 245 ms 25168 KB Output is correct
19 Correct 272 ms 25400 KB Output is correct
20 Correct 250 ms 25276 KB Output is correct
21 Correct 248 ms 25312 KB Output is correct
22 Correct 247 ms 25404 KB Output is correct
23 Correct 260 ms 25168 KB Output is correct
24 Correct 245 ms 25328 KB Output is correct
25 Correct 179 ms 22764 KB Output is correct
26 Correct 183 ms 22796 KB Output is correct
27 Correct 260 ms 24796 KB Output is correct
28 Correct 271 ms 25168 KB Output is correct
29 Correct 279 ms 24548 KB Output is correct
30 Correct 277 ms 24920 KB Output is correct
31 Correct 282 ms 25152 KB Output is correct
32 Correct 166 ms 21332 KB Output is correct
33 Correct 0 ms 348 KB Output is correct