답안 #1094654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094654 2024-09-30T08:29:56 Z thangdz2k7 Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
339 ms 23416 KB
// author : thembululquaUwU
// 3.9.2024

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl '\n'

using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;

const int N = 5e5 + 5;
const int mod = 1e9 + 7;

void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}

int n, a[N], q;

int fd(int t, int up){
    int l = 0, r = n, ans = n + 1;
    while (l <= r){
        int m = l + r >> 1;
        if (t / a[m] * a[m] - m <= up) ans = m, r = m - 1;
        else l = m + 1;
    }
    return n - ans;
}

void solve(){
    cin >> n >> q;
    a[0] = 1;
    for (int i = 1; i <= n; ++ i){
        cin >> a[i];
        a[i] = ((a[i] - 1) / a[i - 1] + 1) * a[i - 1];
    }

    while (q --){
        int t, l, r; cin >> t >> l >> r;
        cout << fd(t, r) - fd(t, l - 1) << endl;
    }
}

int main(){
    if (fopen("pqh.inp", "r")){
        freopen("pqh.inp", "r", stdin);
        freopen("pqh.out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1; // cin >> t;
    while (t --) solve();
    return 0;
}

Compilation message

worst_reporter3.cpp:18:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
worst_reporter3.cpp:18:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
worst_reporter3.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
worst_reporter3.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
worst_reporter3.cpp: In function 'int fd(int, int)':
worst_reporter3.cpp:26:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |         int m = l + r >> 1;
      |                 ~~^~~
worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:50:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 327 ms 20692 KB Output is correct
2 Correct 323 ms 20756 KB Output is correct
3 Correct 325 ms 20820 KB Output is correct
4 Correct 331 ms 20700 KB Output is correct
5 Correct 339 ms 20856 KB Output is correct
6 Correct 326 ms 20816 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 0 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 472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 327 ms 20692 KB Output is correct
2 Correct 323 ms 20756 KB Output is correct
3 Correct 325 ms 20820 KB Output is correct
4 Correct 331 ms 20700 KB Output is correct
5 Correct 339 ms 20856 KB Output is correct
6 Correct 326 ms 20816 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 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 472 KB Output is correct
13 Correct 184 ms 19328 KB Output is correct
14 Correct 194 ms 19796 KB Output is correct
15 Correct 179 ms 18512 KB Output is correct
16 Correct 197 ms 19028 KB Output is correct
17 Correct 269 ms 23376 KB Output is correct
18 Correct 248 ms 23380 KB Output is correct
19 Correct 261 ms 23416 KB Output is correct
20 Correct 250 ms 23404 KB Output is correct
21 Correct 262 ms 23376 KB Output is correct
22 Correct 253 ms 23320 KB Output is correct
23 Correct 251 ms 23248 KB Output is correct
24 Correct 257 ms 23328 KB Output is correct
25 Correct 314 ms 20840 KB Output is correct
26 Correct 320 ms 20816 KB Output is correct
27 Correct 271 ms 22864 KB Output is correct
28 Correct 255 ms 23120 KB Output is correct
29 Correct 252 ms 22868 KB Output is correct
30 Correct 265 ms 22872 KB Output is correct
31 Correct 287 ms 23120 KB Output is correct
32 Correct 244 ms 19244 KB Output is correct
33 Correct 0 ms 344 KB Output is correct