Submission #566756

# Submission time Handle Problem Language Result Execution time Memory
566756 2022-05-22T19:54:08 Z Redhood Kralj (COCI16_kralj) C++14
0 / 140
482 ms 86324 KB
#include <bits/stdc++.h>

using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;

const int N = (int)1e5 + 10;


vector < int > atcur[N];
int main()
{
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n;
    cin >> n;
    vector < int > a(n);
    vector < int > c(n);
    for(auto &i : a)
        cin >> i, --i, c[i]++;


    for(int i = 0; i < n; ++i){
        atcur[a[i]].pb(i);
    }
    vector < int > p(n) , v(n);
    for(auto &i : p)cin >> i;
    for(auto &i : v)cin >> i;



    vector < int > pref(n);
    pref[0] = c[0];
    for(int i = 1; i < n; ++i){
        pref[i] = pref[i - 1] + c[i];
    }
    /// damn
    for(int i = 0; i < n; ++i){
        pref[i] -= i;
    }
    int psmn = min_element(all(pref)) - pref.begin();
    /// okay

    int x = psmn + 1;
    if(x == n)
        x = 0;
    int ans = 0;
    set < int > st;
    for(int it=0;it<n;++it){
        for(auto &u : atcur[x]){
            st.insert(v[u]);
        }
        auto itt = st.lower_bound(p[x]);
        if(itt != st.end()){
            ans++;
            st.erase(itt);
        }
        x++;
        if(x == n)
            x = 0;
    }
    cout << ans;




    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 464 ms 70968 KB Execution killed with signal 11
2 Runtime error 371 ms 69092 KB Execution killed with signal 11
3 Runtime error 455 ms 84684 KB Execution killed with signal 11
4 Runtime error 482 ms 86324 KB Execution killed with signal 11
5 Runtime error 56 ms 15496 KB Execution killed with signal 11
6 Runtime error 50 ms 15540 KB Execution killed with signal 11
7 Runtime error 67 ms 15956 KB Execution killed with signal 11
8 Runtime error 48 ms 14796 KB Execution killed with signal 11
9 Runtime error 60 ms 16708 KB Execution killed with signal 11
10 Runtime error 80 ms 16684 KB Execution killed with signal 11