제출 #443381

#제출 시각아이디문제언어결과실행 시간메모리
443381arujbansalVudu (COCI15_vudu)C++17
42 / 140
1101 ms58916 KiB
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <set> #include <array> #include <stack> #include <queue> #include <random> #include <numeric> #include <functional> #include <chrono> #include <utility> #include <iomanip> #include <assert.h> using namespace std; void dbg_out() { cerr << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); } #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #define rng_init mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) #define rng_seed(x) mt19937 rng(x) #define all(x) (x).begin(), (x).end() #define sz(x) (int) (x).size() // #define int long long #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MXN = 1e5 + 5, INF = 1e9 + 5; void solve() { int N; cin >> N; vector<int> A(N); for (auto &x : A) cin >> x; int P; cin >> P; oset<pair<int, int>> st; int fake_id = 0; st.insert(make_pair(0, fake_id++)); int sum = 0, ans = 0; for (auto &x : A) { sum += x - P; ans += st.order_of_key(make_pair(sum, INF)); st.insert(make_pair(sum, fake_id++)); } cout << ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int TC = 1; // cin >> TC; while (TC--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...