Submission #542459

# Submission time Handle Problem Language Result Execution time Memory
542459 2022-03-26T18:30:21 Z Olympia Vudu (COCI15_vudu) C++17
42 / 140
1000 ms 9344 KB
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>
#include <map>
#include <random>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <limits.h>

using namespace std;
int get (multiset<int>& s, int x) {
    int cntr = 0;
    for (int i: s) {
        if (i <= x) {
            cntr++;
        }
    }

    return cntr;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N; cin >> N;
    vector<int> arr(N); for (int i = 0; i < N; i++) cin >> arr[i];
    vector<int> pref = {0}; for (int i = 0; i < N; i++) pref.push_back(pref.back() + arr[i]);
    int P; cin >> P;
    int c = 0;
    multiset<int> s;
    for (int r = 0; r < N; r++) {
        //for (int l = 0; l <= r; l++) {
        s.insert(pref[r] - P * r);
            c += get(s, pref[r + 1] - P * (r + 1));
            //if (pref[r + 1] - P * r - P >= pref[l] -P * l) {
                //c++;
            //}
        //}
    }
    cout << c;
}
# Verdict Execution time Memory Grader output
1 Correct 257 ms 780 KB Output is correct
2 Correct 152 ms 852 KB Output is correct
3 Correct 143 ms 524 KB Output is correct
4 Execution timed out 1089 ms 8984 KB Time limit exceeded
5 Execution timed out 1074 ms 7212 KB Time limit exceeded
6 Execution timed out 1082 ms 8396 KB Time limit exceeded
7 Execution timed out 1076 ms 8516 KB Time limit exceeded
8 Execution timed out 1074 ms 8056 KB Time limit exceeded
9 Execution timed out 1087 ms 9344 KB Time limit exceeded
10 Execution timed out 1083 ms 8452 KB Time limit exceeded