답안 #684800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
684800 2023-01-22T13:30:16 Z US3RN4M3 Vudu (COCI15_vudu) C++17
126 / 140
891 ms 65536 KB
#include<ext/pb_ds/assoc_container.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
typedef tree<pair<ll, int>, null_type, less<pair<ll, 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;
	ost t;
	ll sum = 0;
	ll ans = 0;
	t.insert({0, -1});
	for(int i = 0; i < n; i++) {
		sum += nums[i];
		ll goal = p * (i + 1);
		ans += i + 1 - t.order_of_key({goal - sum, -1});
		t.insert({goal - sum, i});
	}
	cout << ans << endl;
}

Compilation message

vudu.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 724 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 5 ms 596 KB Output is correct
4 Correct 891 ms 65536 KB Output is correct
5 Correct 463 ms 36556 KB Output is correct
6 Correct 718 ms 57144 KB Output is correct
7 Correct 768 ms 61940 KB Output is correct
8 Correct 677 ms 51592 KB Output is correct
9 Runtime error 837 ms 65536 KB Execution killed with signal 9
10 Correct 801 ms 58896 KB Output is correct