답안 #242213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
242213 2020-06-27T06:07:17 Z SomeoneUnknown Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
792 ms 5624 KB
#include <bits/stdc++.h>
using namespace std;

int posof(int slow, int id, int tiem){
    //printf("%d at pos %d at time %d\n", id, (tiem/slow)*slow-id, tiem);
    return (tiem/slow)*slow-id;
}

int main(){
    int n, q;
    scanf("%d %d", &n, &q);
    int dancers[n+1];
    dancers[0] = 1;
    for(int i = 0; i < n; ++i){
        scanf("%d", &dancers[i+1]);
        --dancers[i+1];
        dancers[i+1] /= dancers[i];
        ++dancers[i+1];
        dancers[i+1] *= dancers[i];
    }
    for(int i = 0; i < q; ++i){
        int t,s,e;
        scanf("%d %d %d", &t, &s, &e);
        ++e;
        int lo, hi;
        //Find how many dancers are after the end
        lo = -1;
        hi = n+1;
        int mid;
        while(hi-lo>1){
            mid = (hi+lo)/2;
            if(posof(dancers[mid],mid,t) < e){
                hi = mid;
            }else{
                lo = mid;
            }
        }
        e = hi;
        //Find how many dancers are after the start
        lo = -1;
        hi = n+1;
        while(hi-lo>1){
            mid = (hi+lo)/2;
            if(posof(dancers[mid],mid,t) < s){
                hi = mid;
            }else{
                lo = mid;
            }
        }
        s = hi;
        printf("%d\n",s-e);
    }
}
/*
3 6
2
5
3
1 2 4
2 2 4
3 2 4
4 2 4
5 2 4
6 2 4
*/

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &dancers[i+1]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &t, &s, &e);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 738 ms 5368 KB Output is correct
2 Correct 748 ms 5344 KB Output is correct
3 Correct 734 ms 5368 KB Output is correct
4 Correct 740 ms 5240 KB Output is correct
5 Correct 720 ms 5496 KB Output is correct
6 Correct 756 ms 5624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 738 ms 5368 KB Output is correct
2 Correct 748 ms 5344 KB Output is correct
3 Correct 734 ms 5368 KB Output is correct
4 Correct 740 ms 5240 KB Output is correct
5 Correct 720 ms 5496 KB Output is correct
6 Correct 756 ms 5624 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 6 ms 256 KB Output is correct
13 Correct 574 ms 3320 KB Output is correct
14 Correct 551 ms 3448 KB Output is correct
15 Correct 540 ms 3304 KB Output is correct
16 Correct 542 ms 3468 KB Output is correct
17 Correct 617 ms 4728 KB Output is correct
18 Correct 613 ms 4856 KB Output is correct
19 Correct 609 ms 4856 KB Output is correct
20 Correct 598 ms 4772 KB Output is correct
21 Correct 602 ms 4728 KB Output is correct
22 Correct 617 ms 4856 KB Output is correct
23 Correct 628 ms 4940 KB Output is correct
24 Correct 620 ms 4984 KB Output is correct
25 Correct 792 ms 5496 KB Output is correct
26 Correct 731 ms 5240 KB Output is correct
27 Correct 657 ms 5112 KB Output is correct
28 Correct 665 ms 5160 KB Output is correct
29 Correct 642 ms 5112 KB Output is correct
30 Correct 698 ms 5180 KB Output is correct
31 Correct 646 ms 5088 KB Output is correct
32 Correct 625 ms 5092 KB Output is correct
33 Correct 5 ms 256 KB Output is correct