답안 #542471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
542471 2022-03-26T18:40:28 Z Olympia Vudu (COCI15_vudu) C++17
112 / 140
581 ms 65536 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

typedef
tree<
pair<int64_t,int64_t>,
null_type,
less<pair<int64_t,int64_t>>,
rb_tree_tag,
tree_order_statistics_node_update>
        ordered_set;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N; cin >> N;
    vector<int64_t> pref = {0}; for (int i = 0; i < N; i++) {int64_t x; cin >> x; pref.push_back(pref.back() + x);}
    int64_t P; cin >> P;
    int64_t c = 0;
    ordered_set s;
    for (int r = 0; r < N; r++) {
        s.insert({pref[r] - P * r, r});
        c += (int64_t)s.order_of_key(make_pair(pref[r + 1] - P * (r + 1) + 1, -1));
    }
    cout << c;
}

Compilation message

vudu.cpp:17: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   17 | #pragma GCC optimization ("O3")
      | 
vudu.cpp:18: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   18 | #pragma GCC optimization ("unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 852 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 3 ms 724 KB Output is correct
4 Runtime error 581 ms 65536 KB Execution killed with signal 9
5 Correct 357 ms 38884 KB Output is correct
6 Correct 522 ms 60556 KB Output is correct
7 Correct 504 ms 62964 KB Output is correct
8 Correct 529 ms 54624 KB Output is correct
9 Runtime error 520 ms 65536 KB Execution killed with signal 9
10 Correct 530 ms 61336 KB Output is correct