답안 #256567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256567 2020-08-02T21:03:48 Z ElyesChaabouni Vudu (COCI15_vudu) C++17
0 / 140
23 ms 2560 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000001
#define PI 3.14159265358979323846
#define ordered_set tree<pair<long long, int>, null_type,less<pair<long long, int> >, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int a[n];
	ordered_set s;
	//cout << n << '\n';
	for(int i = 0; i < n; i++)
		cin >> a[i];
	long long p;
	cin >> p;
	long long sum=0, cu=0, ans=0;
	for(int i = n-1; i >= 0; i--)
	{
		sum+=a[i];
		s.insert(make_pair(sum-cu, i));
		//cout << here[i] << ' ';
		cu+=p;
	}
	//cout << '\n';
	cu=0;
	sum=0;
	for(int i = n-1; i >= 0; i--)
	{
		ordered_set::iterator it=s.lower_bound(make_pair(p+sum-cu, -1));
		if(it!=s.end())
			ans+=i+1-s.order_of_key(*it);
		//cout << s.order_of_key(*s.lower_bound(make_pair(p+pr-cu, -1))) << '\n';
		sum+=a[i];
		s.erase(make_pair(sum-cu, i));
		cu+=p;
	}
	cout << ans << '\n';
}

Compilation message

vudu.cpp: In function 'int main()':
vudu.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("input.txt", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
vudu.cpp:17:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("output.txt", "w", stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 2432 KB Output isn't correct
2 Incorrect 21 ms 2432 KB Output isn't correct
3 Incorrect 22 ms 2424 KB Output isn't correct
4 Incorrect 21 ms 2432 KB Output isn't correct
5 Incorrect 22 ms 2432 KB Output isn't correct
6 Incorrect 20 ms 2432 KB Output isn't correct
7 Incorrect 21 ms 2432 KB Output isn't correct
8 Incorrect 23 ms 2560 KB Output isn't correct
9 Incorrect 18 ms 2432 KB Output isn't correct
10 Incorrect 19 ms 2432 KB Output isn't correct