답안 #542461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
542461 2022-03-26T18:31:41 Z Olympia Vudu (COCI15_vudu) C++17
42 / 140
1000 ms 8704 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 (set<pair<int,int>>& s, int x) {
    int cntr = 0;
    for (auto& i: s) {
        if (i.first <= 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;
    set<pair<int,int>> s;
    for (int r = 0; r < N; r++) {
        //for (int l = 0; l <= r; l++) {
        s.insert({pref[r] - P * r, r});
            c += get(s, pref[r + 1] - P * (r + 1));
            //if (pref[r + 1] - P * r - P >= pref[l] -P * l) {
                //c++;
            //}
        //}
    }
    cout << c;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 282 ms 672 KB Output is correct
2 Correct 153 ms 616 KB Output is correct
3 Correct 147 ms 584 KB Output is correct
4 Execution timed out 1074 ms 8480 KB Time limit exceeded
5 Execution timed out 1066 ms 6668 KB Time limit exceeded
6 Execution timed out 1095 ms 7876 KB Time limit exceeded
7 Execution timed out 1092 ms 8040 KB Time limit exceeded
8 Execution timed out 1050 ms 7548 KB Time limit exceeded
9 Execution timed out 1090 ms 8704 KB Time limit exceeded
10 Execution timed out 1080 ms 7936 KB Time limit exceeded