답안 #1023736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023736 2024-07-15T05:44:29 Z manizare Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
510 ms 33056 KB
#include <bits/stdc++.h>
 
 
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second 
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define PII pair<pii , pii>
#define ld long double 
#define int long long 
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= b;i++)
#define per(i, a , b) for(int i=a;i >= b;i--)
using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 5e5 + 10  , sq = 550,  inf = 1e8+10 , mod = 10007 , lg = 20  ;
int n , q , d[maxn] , s[maxn] , t[maxn] ; 

int que(int x , int f){
    int l = -1 , r = n+1 ;
    while(r-l>1){
        int m =(l+r)/2 ;
        int ted = f/t[m] ;
        int x2 = -m + ted * s[m] ; 
        if(x2 <= x){
            r = m ; 
        }else{
            l = m ;
        }  
    }
    return n+1-r ; 
}

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);    
    cin >> n >> q ; 
    s[0] = t[0] = 1;bool ok = 0;  
    rep(i ,1 , n){
        cin>> d[i] ; 
        if(ok == 1)continue ; 
        int ted = (d[i] + s[i-1]-1)/s[i-1] ; 
        s[i] = ted * s[i-1]; 
        t[i] = ted * t[i-1] ; 
        if(t[i] > 1e9){
            ok = 1 ;
            rep(j , i+1 , n)t[j] = t[j-1] ; 

        }
    }
    while(q--){
        int l , r , ti ;cin >> ti >> l >> r; 
        cout << que(r , ti) - que(l-1 ,ti) << "\n" ; 
    }   
}
/*
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 30580 KB Output is correct
2 Correct 483 ms 30432 KB Output is correct
3 Correct 510 ms 30548 KB Output is correct
4 Correct 451 ms 30548 KB Output is correct
5 Correct 449 ms 30580 KB Output is correct
6 Correct 431 ms 30544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 30580 KB Output is correct
2 Correct 483 ms 30432 KB Output is correct
3 Correct 510 ms 30548 KB Output is correct
4 Correct 451 ms 30548 KB Output is correct
5 Correct 449 ms 30580 KB Output is correct
6 Correct 431 ms 30544 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 283 ms 25212 KB Output is correct
14 Correct 306 ms 25728 KB Output is correct
15 Correct 268 ms 24404 KB Output is correct
16 Correct 280 ms 24868 KB Output is correct
17 Correct 358 ms 32080 KB Output is correct
18 Correct 347 ms 31776 KB Output is correct
19 Correct 338 ms 31628 KB Output is correct
20 Correct 382 ms 32084 KB Output is correct
21 Correct 371 ms 31824 KB Output is correct
22 Correct 366 ms 31568 KB Output is correct
23 Correct 379 ms 32340 KB Output is correct
24 Correct 351 ms 31572 KB Output is correct
25 Correct 453 ms 30728 KB Output is correct
26 Correct 455 ms 30632 KB Output is correct
27 Correct 416 ms 32592 KB Output is correct
28 Correct 363 ms 33056 KB Output is correct
29 Correct 365 ms 30292 KB Output is correct
30 Correct 389 ms 31144 KB Output is correct
31 Correct 377 ms 32848 KB Output is correct
32 Correct 380 ms 29268 KB Output is correct
33 Correct 0 ms 344 KB Output is correct