Submission #242208

# Submission time Handle Problem Language Result Execution time Memory
242208 2020-06-27T05:38:38 Z dwsc Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
635 ms 7608 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,q;
    cin >> n >> q;
    int arr[n+1];
    arr[0] = 1;
    for (int i = 1; i <= n; i++){
        cin >> arr[i];
        arr[i] = ((arr[i]+arr[i-1]-1)/arr[i-1])*arr[i-1];
        //cout << arr[i] << "\n";
    }
    for (int i = 0; i < q; i++){
        int l,r,t;
        cin >> t>> l >> r;
        int lo1 = 0,hi1 = n+1;
        int ans1 = -1;
        while (lo1 != hi1){
            int m = (lo1+hi1)/2;
            int travel = (t/arr[m])*arr[m];
            int newcoord = -m+travel;
            if (newcoord <= r){
                hi1 = m;
                ans1 = m;
            }
            else{
                lo1 = m+1;
            }
        }
        int lo2 = 0,hi2 = n+1;
        int ans2 = -1;
        while (lo2 != hi2){
            int m = (lo2+hi2)/2;
            int travel = (t/arr[m])*arr[m];
            int newcoord = -m+travel;
            if (newcoord >= l){
                lo2 = m+1;
                ans2 = m;
            }
            else{
                hi2 = m;
            }
        }
       // cout << ans1 << " " << ans2 << "hi\n";
        if (ans1 == -1 || ans2 == -1 || ans2 < ans1) cout << 0 << "\n";
        else cout << ans2-ans1+1 << "\n";
    }
}

Compilation message

worst_reporter3.cpp:4:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Correct 623 ms 7408 KB Output is correct
2 Correct 635 ms 7288 KB Output is correct
3 Correct 624 ms 7376 KB Output is correct
4 Correct 614 ms 7416 KB Output is correct
5 Correct 608 ms 7416 KB Output is correct
6 Correct 623 ms 7288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 623 ms 7408 KB Output is correct
2 Correct 635 ms 7288 KB Output is correct
3 Correct 624 ms 7376 KB Output is correct
4 Correct 614 ms 7416 KB Output is correct
5 Correct 608 ms 7416 KB Output is correct
6 Correct 623 ms 7288 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 395 ms 5476 KB Output is correct
14 Correct 397 ms 5368 KB Output is correct
15 Correct 378 ms 5368 KB Output is correct
16 Correct 415 ms 5368 KB Output is correct
17 Correct 486 ms 6776 KB Output is correct
18 Correct 481 ms 6648 KB Output is correct
19 Correct 487 ms 6648 KB Output is correct
20 Correct 496 ms 6776 KB Output is correct
21 Correct 488 ms 6804 KB Output is correct
22 Correct 480 ms 6892 KB Output is correct
23 Correct 498 ms 6904 KB Output is correct
24 Correct 494 ms 6904 KB Output is correct
25 Correct 623 ms 7608 KB Output is correct
26 Correct 632 ms 7288 KB Output is correct
27 Correct 525 ms 7160 KB Output is correct
28 Correct 512 ms 7160 KB Output is correct
29 Correct 503 ms 7160 KB Output is correct
30 Correct 527 ms 7288 KB Output is correct
31 Correct 532 ms 6976 KB Output is correct
32 Correct 495 ms 6924 KB Output is correct
33 Correct 5 ms 384 KB Output is correct