답안 #1039775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039775 2024-07-31T08:51:07 Z Andrey Worst Reporter 3 (JOI18_worst_reporter3) C++14
19 / 100
335 ms 20820 KB
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,q,a,b,t;
    cin >> n >> q;
    vector<int> haha(n+1,1);
    for(int i = 1; i <= n; i++) {
        cin >> haha[i];
        haha[i] = haha[i-1]*((haha[i]+haha[i-1]-1)/haha[i-1]);
    }
    for(int i = 0; i < q; i++) {
        cin >> t >> a >> b;
        int c = a,ans = 0;
        if(t >= c) {
            int l = 0,r = haha.size()-1;
            while(l < r) {
                int mid = (l+r+1)/2;
                if(-mid+haha[mid]*(t/haha[mid]) >= c) {
                    l = mid;
                }
                else {
                    r = mid-1;
                }
            }
            ans+=l+1;
        }
        c = b+1;
        if(t >= c) {
            int l = 0,r = haha.size()-1;
            while(l < r) {
                int mid = (l+r+1)/2;
                if(-mid+haha[mid]*(t/haha[mid]) >= c) {
                    l = mid;
                }
                else {
                    r = mid-1;
                }
            }
            ans-=l+1;
        }
        cout << ans << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 335 ms 20748 KB Output is correct
2 Correct 316 ms 20700 KB Output is correct
3 Correct 307 ms 20816 KB Output is correct
4 Correct 308 ms 20816 KB Output is correct
5 Correct 309 ms 20820 KB Output is correct
6 Correct 282 ms 20816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 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 335 ms 20748 KB Output is correct
2 Correct 316 ms 20700 KB Output is correct
3 Correct 307 ms 20816 KB Output is correct
4 Correct 308 ms 20816 KB Output is correct
5 Correct 309 ms 20820 KB Output is correct
6 Correct 282 ms 20816 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 472 KB Output is correct
13 Runtime error 4 ms 4696 KB Execution killed with signal 8
14 Halted 0 ms 0 KB -