Submission #684804

#TimeUsernameProblemLanguageResultExecution timeMemory
684804US3RN4M3Vudu (COCI15_vudu)C++17
126 / 140
988 ms65536 KiB
#include<ext/pb_ds/assoc_container.hpp> #include<bits/stdc++.h> using namespace std; using namespace __gnu_pbds; using ll = long long; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost; main() { int n; cin >> n; vector<int> nums(n); for(int & i : nums) cin >> i; ll p; cin >> p; vector<pair<ll, int>> vals(n); ll sum = 0; ll ans = 0; for(int i = 0; i < n; i++) { sum += nums[i]; ll goal = p*(i + 1); vals[i] = {sum - goal, i}; if(sum >= goal) ans++; } sort(vals.begin(), vals.end()); ost t; for(int i = 0; i < n; i++) { ans += t.order_of_key(vals[i].second); t.insert(vals[i].second); } cout << ans << endl; }

Compilation message (stderr)

vudu.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...