답안 #1053500

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053500 2024-08-11T12:39:43 Z anton Lottery (CEOI18_lot) C++17
80 / 100
3000 ms 5180 KB
#include<bits/stdc++.h>

using namespace std;
#define pii pair<int, int>
int L, N;
int M;

int get_pos(vector<int>& v, int i){
    int res =0;
    for(int step =(1<<20); step>=1; step/=2){
        if(res + step < v.size() && v[res+step]<=i){
            res += step;
        }
    }
    return res;
}

struct Summer{
    vector<int> ev;

    Summer(int n){
        ev.resize(n+1);
    }


    void add_inc(int l, int r){
        ev[l]++;
        ev[r+1]--;
    }

    vector<int> calc(){
        vector<int> res;
        int cur_s = 0;
        for(int i = 0; i<ev.size()-1; i++){
            
            cur_s += ev[i];
            
            res.push_back(cur_s);
        }
        return res;
    }
};

signed main(){
    cin>>N>>L;
    M = N-L+1;
    vector<int> a(N);
    vector<int> vals;

    for(int i= 0; i<N; i++){
        cin>>a[i];
        vals.push_back(a[i]);
    }

    sort(vals.begin(), vals.end());

    for(int i = 0; i<N; i++){
        a[i] = get_pos(vals, a[i]);
    }

    int Q;
    cin>>Q;

    vector<int> lims(Q);
    for(int i = 0; i<Q; i++){
        cin>>lims[i];
    }

        vector<vector<int>> score(M, vector<int>(Q, 0));

    for(int len = 1; len<N; len++){

        Summer sum(N+1);
        for(int i = N-1; i>=0; i--){
            int cur_a = a[i];
            if(i+len <N && a[i+len]==a[i]){
                sum.add_inc(max(0, i-L+1),i);
            }
        }

        vector<int> dists = sum.calc();
        sum.ev.clear();
        for(int i = 0; i+len<M; i++){
            for(int q=  0; q<Q; q++){
                if(dists[i]>=L-lims[q]){
                    score[i][q]++;
                    score[i+len][q]++;
                }
            }
        }
    }

    
    for(int q = 0; q<Q; q++){
        for(int i = 0; i<M; i++){
           cout<<score[i][q]<<" ";
        }
        cout<<endl;
    }

}

Compilation message

lot.cpp: In function 'int get_pos(std::vector<int>&, int)':
lot.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |         if(res + step < v.size() && v[res+step]<=i){
      |            ~~~~~~~~~~~^~~~~~~~~~
lot.cpp: In member function 'std::vector<int> Summer::calc()':
lot.cpp:34:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i = 0; i<ev.size()-1; i++){
      |                        ~^~~~~~~~~~~~
lot.cpp: In function 'int main()':
lot.cpp:75:17: warning: unused variable 'cur_a' [-Wunused-variable]
   75 |             int cur_a = a[i];
      |                 ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 612 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 612 KB Output is correct
13 Correct 18 ms 604 KB Output is correct
14 Correct 20 ms 604 KB Output is correct
15 Correct 15 ms 604 KB Output is correct
16 Correct 29 ms 676 KB Output is correct
17 Correct 25 ms 604 KB Output is correct
18 Correct 26 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 618 ms 1116 KB Output is correct
2 Correct 583 ms 1212 KB Output is correct
3 Correct 428 ms 1116 KB Output is correct
4 Correct 390 ms 1116 KB Output is correct
5 Correct 366 ms 1108 KB Output is correct
6 Correct 404 ms 1272 KB Output is correct
7 Correct 459 ms 1104 KB Output is correct
8 Correct 412 ms 1132 KB Output is correct
9 Correct 394 ms 1112 KB Output is correct
10 Correct 399 ms 1284 KB Output is correct
11 Correct 35 ms 604 KB Output is correct
12 Correct 325 ms 1120 KB Output is correct
13 Correct 371 ms 1072 KB Output is correct
14 Correct 367 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 618 ms 1116 KB Output is correct
2 Correct 583 ms 1212 KB Output is correct
3 Correct 428 ms 1116 KB Output is correct
4 Correct 390 ms 1116 KB Output is correct
5 Correct 366 ms 1108 KB Output is correct
6 Correct 404 ms 1272 KB Output is correct
7 Correct 459 ms 1104 KB Output is correct
8 Correct 412 ms 1132 KB Output is correct
9 Correct 394 ms 1112 KB Output is correct
10 Correct 399 ms 1284 KB Output is correct
11 Correct 35 ms 604 KB Output is correct
12 Correct 325 ms 1120 KB Output is correct
13 Correct 371 ms 1072 KB Output is correct
14 Correct 367 ms 860 KB Output is correct
15 Correct 443 ms 1224 KB Output is correct
16 Correct 390 ms 1244 KB Output is correct
17 Correct 406 ms 1116 KB Output is correct
18 Correct 404 ms 1296 KB Output is correct
19 Correct 395 ms 1116 KB Output is correct
20 Correct 400 ms 1116 KB Output is correct
21 Correct 484 ms 1360 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 612 KB Output is correct
13 Correct 18 ms 604 KB Output is correct
14 Correct 20 ms 604 KB Output is correct
15 Correct 15 ms 604 KB Output is correct
16 Correct 29 ms 676 KB Output is correct
17 Correct 25 ms 604 KB Output is correct
18 Correct 26 ms 600 KB Output is correct
19 Correct 618 ms 1116 KB Output is correct
20 Correct 583 ms 1212 KB Output is correct
21 Correct 428 ms 1116 KB Output is correct
22 Correct 390 ms 1116 KB Output is correct
23 Correct 366 ms 1108 KB Output is correct
24 Correct 404 ms 1272 KB Output is correct
25 Correct 459 ms 1104 KB Output is correct
26 Correct 412 ms 1132 KB Output is correct
27 Correct 394 ms 1112 KB Output is correct
28 Correct 399 ms 1284 KB Output is correct
29 Correct 35 ms 604 KB Output is correct
30 Correct 325 ms 1120 KB Output is correct
31 Correct 371 ms 1072 KB Output is correct
32 Correct 367 ms 860 KB Output is correct
33 Correct 443 ms 1224 KB Output is correct
34 Correct 390 ms 1244 KB Output is correct
35 Correct 406 ms 1116 KB Output is correct
36 Correct 404 ms 1296 KB Output is correct
37 Correct 395 ms 1116 KB Output is correct
38 Correct 400 ms 1116 KB Output is correct
39 Correct 484 ms 1360 KB Output is correct
40 Correct 1678 ms 2412 KB Output is correct
41 Correct 473 ms 996 KB Output is correct
42 Correct 1158 ms 2388 KB Output is correct
43 Correct 1010 ms 2240 KB Output is correct
44 Correct 1073 ms 2132 KB Output is correct
45 Execution timed out 3058 ms 5180 KB Time limit exceeded
46 Halted 0 ms 0 KB -