Submission #1231262

#TimeUsernameProblemLanguageResultExecution timeMemory
1231262banganNile (IOI24_nile)C++20
0 / 100
23 ms4284 KiB
#include "nile.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define ALL(a) a.begin(), a.end()

std::vector<long long> calculate_costs(std::vector<int> W, std::vector<int> A, std::vector<int> B, std::vector<int> E) {
    int N = W.size();
    int Q = E.size();

    vector<int> ord(N);
    iota(ALL(ord), 0);
    sort(ALL(ord), [&](int i, int j) {
        return W[i]<W[j];
    });

    vector<ll> ret;
    for (int D : E) {
        for (int i=0; i<N;) {
            int j = i+1;
            while (j<N && W[ord[j]] - W[ord[j-1]] <= D) j++;
        
            int sz = j-i;
            if (sz%2 == 0) ret.pb(sz);
            else ret.pb(sz+1);
            i=j;
        }
    }
    return ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...