답안 #206702

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206702 2020-03-04T16:06:38 Z nvmdava Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
416 ms 8312 KB
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define ff first
#define ss second
#define N 500005
#define MOD 1000000007
#define INF 0x3f3f3f3f

int a[N];

vector<pair<int, pair<int, int> > > v;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin>>n>>q;
    
    for(int i = 1; i <= n; ++i)
        cin>>a[i];
    for(int i = 2; i <= n; ++i)
        a[i] = ((a[i] - 1) / a[i - 1] + 1) * a[i - 1];

    for(int i = 1; i <= n; ++i){
        if(a[i] != a[i - 1]){
            v.push_back({a[i], {-i, -i}});
        } else {
            v.back().ss.ff = -i;
        }
    }

    while(q--){
        int t, l, r;
        cin>>t>>l>>r;
        int m = t;
        int res = 0;
        if(l <= m && m <= r)
            ++res;
        for(auto& x : v){
            int L = x.ss.ff, R = x.ss.ss;
            int val = (m - R - 1) / x.ff * x.ff;
            L += val;
            R += val;
            res += max(0, min(R, r) - max(l, L) + 1);
            m = L;
            if(m <= l) break;
        }
        cout<<res<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 5500 KB Output is correct
2 Correct 293 ms 5496 KB Output is correct
3 Correct 291 ms 5496 KB Output is correct
4 Correct 301 ms 5560 KB Output is correct
5 Correct 312 ms 5496 KB Output is correct
6 Correct 283 ms 5496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 5500 KB Output is correct
2 Correct 293 ms 5496 KB Output is correct
3 Correct 291 ms 5496 KB Output is correct
4 Correct 301 ms 5560 KB Output is correct
5 Correct 312 ms 5496 KB Output is correct
6 Correct 283 ms 5496 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 312 ms 7832 KB Output is correct
14 Correct 298 ms 3448 KB Output is correct
15 Correct 299 ms 7928 KB Output is correct
16 Correct 299 ms 7864 KB Output is correct
17 Correct 399 ms 4900 KB Output is correct
18 Correct 378 ms 4856 KB Output is correct
19 Correct 398 ms 4856 KB Output is correct
20 Correct 390 ms 5012 KB Output is correct
21 Correct 387 ms 4856 KB Output is correct
22 Correct 397 ms 4888 KB Output is correct
23 Correct 388 ms 4932 KB Output is correct
24 Correct 382 ms 4984 KB Output is correct
25 Correct 312 ms 8312 KB Output is correct
26 Correct 300 ms 8112 KB Output is correct
27 Correct 404 ms 5496 KB Output is correct
28 Correct 416 ms 5112 KB Output is correct
29 Correct 411 ms 5200 KB Output is correct
30 Correct 390 ms 5368 KB Output is correct
31 Correct 410 ms 5240 KB Output is correct
32 Correct 291 ms 5752 KB Output is correct
33 Correct 5 ms 376 KB Output is correct