Submission #2873155
Source Code Expand
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>
#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define ll long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;
const ll MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);
//変数
int N;
ll K;
vector<ll> a;
//サブ関数
//入力
void input()
{
cin >> N >> K;
a.resize(N + 1);
REP(i, N)cin >> a[i + 1];
REP(i, N)a[i + 1] -= K;
REP(i, N)a[i + 1] += a[i];
}
vector<pair<ll, ll>> make_sample(vector<ll> a)
{
vector<pair<ll, ll>> sample;
REP(i, N + 1)sample.push_back({ a[i],i });
sort(sample.begin(), sample.end());
return sample;
}
void erase_target(vector<pair<ll, ll>>& sample, pair<ll,ll> alpha)
{
auto itr = lower_bound(sample.begin(), sample.end(), alpha);
if (alpha != *itr)exit(1);
sample.erase(itr);
}
ll count(vector<pair<ll, ll>>& sample, pair<ll, ll> alpha)
{
erase_target(sample, alpha);
//alpha.second = -1;
return distance(lower_bound(sample.begin(), sample.end(), alpha), sample.end());
}
//計算
void calc()
{
ll res = 0;
auto sample = make_sample(a);
REP(i, N+1)res += count(sample, { a[i],i });
cout << res << endl;
}
//出力
void output()
{
}
//デバッグ
void debug()
{
int N;
cin>>N;
}
//メイン関数
int main()
{
input();
calc();
output();
debug();
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Meaningful Mean |
User |
toma25 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1724 Byte |
Status |
TLE |
Exec Time |
2103 ms |
Memory |
9584 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 600 |
Status |
|
|
Set Name |
Test Cases |
Sample |
a01, a02, a03 |
All |
a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23 |
Case Name |
Status |
Exec Time |
Memory |
a01 |
AC |
1 ms |
256 KB |
a02 |
AC |
1 ms |
256 KB |
a03 |
AC |
1 ms |
256 KB |
b04 |
AC |
1 ms |
256 KB |
b05 |
TLE |
2103 ms |
9584 KB |
b06 |
AC |
100 ms |
8176 KB |
b07 |
TLE |
2103 ms |
9072 KB |
b08 |
TLE |
2103 ms |
7664 KB |
b09 |
TLE |
2103 ms |
9328 KB |
b10 |
TLE |
2103 ms |
9328 KB |
b11 |
AC |
1 ms |
256 KB |
b12 |
AC |
2 ms |
256 KB |
b13 |
AC |
382 ms |
3572 KB |
b14 |
TLE |
2103 ms |
8816 KB |
b15 |
AC |
54 ms |
9584 KB |
b16 |
TLE |
2103 ms |
9456 KB |
b17 |
TLE |
2103 ms |
8560 KB |
b18 |
TLE |
2103 ms |
9456 KB |
b19 |
AC |
100 ms |
9328 KB |
b20 |
TLE |
2103 ms |
9200 KB |
b21 |
TLE |
2103 ms |
7792 KB |
b22 |
TLE |
2103 ms |
7664 KB |
b23 |
TLE |
2103 ms |
8560 KB |