Submission #1059916

# Submission time Handle Problem Language Result Execution time Memory
1059916 2024-08-15T09:09:57 Z SzymonKrzywda Lottery (CEOI18_lot) C++17
25 / 100
2205 ms 65536 KB
#include <bits/stdc++.h>

using namespace std;



int main()
{
    int n,l;
    cin >> n >> l;
    int tab[n];
    int odp[(n-l+1)][l+1];
    for (int i=0; i<n; i++){
        cin >> tab[i];
    }
    map<pair<int,int>,vector<int>> mapa;
    for (int i=0; i<(n-l+1); i++){
        
        for (int j=0; j<l; j++){
            if (mapa.find({j,tab[i+j]}) != mapa.end()){
                mapa[{j,tab[i+j]}].push_back(i);
            }
            else{
                mapa[{j,tab[i+j]}] = {i};
            }
        }

        
        
    }
    
    for (int i=0; i<(n-l+1); i++){
        int wyniki_2[n];
        for (int s=0; s<n; s++) wyniki_2[s] = 0;
        for (int j=i; j<(i+l); j++){
            
            for (int s : mapa[{j-i,tab[j]}]){
                if (i==s) continue;
                //cout << i << " " << " " << tab[j] << " " << s << endl;
                wyniki_2[s]++;
            }
            
        }
        
        vector<int> wyniki(0);
        int maxi=0;
        for (int s=0; s<(n-l+1); s++){
            if (i==s) continue;
            //cout << s << ": " << wyniki_2[s] << " ";
            wyniki.push_back(wyniki_2[s]);
        }
        //cout << endl;
        sort(wyniki.begin(),wyniki.end());
        //for (auto x : wyniki) cout << x << " ";cout << endl;
        int ile=(n-l);
        int wsk=0;
        for (int x=l; x>=0; x--){
            //if (wsk<(n-l)) cout << x << " " << ile << " " << wsk << " " << wyniki[wsk] << endl;
            odp[i][x] = ile;
            //cout << odp[i][x] << endl;
            while (wsk < (n-l) && l-wyniki[wsk]==x) {ile--; wsk++;}
        }
    }
    
    
    int q,k;
    
    cin >> q;
    
    for (int i=0; i<q; i++){
        cin >> k;
        for (int j=0; j<(n-l+1); j++){
            cout << odp[j][k]<< " ";
        }
        cout << endl;
    }

    return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:46:13: warning: unused variable 'maxi' [-Wunused-variable]
   46 |         int maxi=0;
      |             ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 436 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 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 8 ms 1044 KB Output is correct
9 Correct 5 ms 860 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 3 ms 600 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 436 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 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 8 ms 1044 KB Output is correct
9 Correct 5 ms 860 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 3 ms 600 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
13 Correct 58 ms 544 KB Output is correct
14 Runtime error 348 ms 65536 KB Execution killed with signal 9
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1779 ms 960 KB Output is correct
2 Correct 2205 ms 1112 KB Output is correct
3 Correct 1536 ms 944 KB Output is correct
4 Correct 2093 ms 23888 KB Output is correct
5 Runtime error 37 ms 65536 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1779 ms 960 KB Output is correct
2 Correct 2205 ms 1112 KB Output is correct
3 Correct 1536 ms 944 KB Output is correct
4 Correct 2093 ms 23888 KB Output is correct
5 Runtime error 37 ms 65536 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 436 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 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 8 ms 1044 KB Output is correct
9 Correct 5 ms 860 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 3 ms 600 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
13 Correct 58 ms 544 KB Output is correct
14 Runtime error 348 ms 65536 KB Execution killed with signal 9
15 Halted 0 ms 0 KB -