답안 #135134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
135134 2019-07-23T16:36:22 Z doowey Worst Reporter 3 (JOI18_worst_reporter3) C++14
12 / 100
12 ms 2424 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
const int N = (int)1e5 + 9;
const ll MAX = (ll)5e9;
ll per[N];

ll compute(int id, ll tim){
    return (tim-(tim%per[id]))-id;
}

int main(){
    fastIO;
    int n, q;
    cin >> n >> q;
    cin >> per[1];
    for(int i = 2; i <= n; i ++ ){
        cin >> per[i];
        per[i] = (per[i - 1] * ((per[i] - 1) / per[i-1] + 1));
        per[i] = min(per[i], MAX);
    }
    ll L, R, T;
    ll res;
    int lf, rf, md;
    int p1, p2;
    for(int i = 0 ; i < q; i ++ ){
        cin >> T >> L >> R;
        p1 = 0;
        p2 = n;
        for(int j = 19; j >= 0 ; j -- ){
            if(p1 + (1 << j) <= n){
                if(compute(p1 + (1 << j), T) >= L)
                    p1 += (1 << j);
            }
            if(p2 - (1 << j) >= 1){
                if(compute(p2 - (1 << j), T) <= R){
                    p2 -= (1 << j);
                }
            }
        }
        cout << max(0, p1 - p2 + 1) + (T >= L && T <= R) << "\n";
    }
    return 0;
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:33:8: warning: unused variable 'res' [-Wunused-variable]
     ll res;
        ^~~
worst_reporter3.cpp:34:9: warning: unused variable 'lf' [-Wunused-variable]
     int lf, rf, md;
         ^~
worst_reporter3.cpp:34:13: warning: unused variable 'rf' [-Wunused-variable]
     int lf, rf, md;
             ^~
worst_reporter3.cpp:34:17: warning: unused variable 'md' [-Wunused-variable]
     int lf, rf, md;
                 ^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 2424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 372 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 2424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -