//Invitation to ICO Preparatory Contest #1
//ICOP1901
//mean array
/************************************************************************************************************************************************************************************
* *
* *
* **************** ************** * * **************** * * **************** * * **************** **************** *
* * * * * * * * * ** * * * * * * * *
* * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * *
* **************** ************** ***************** **************** * * * * **************** * * **************** *
* * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * *
* * * * * * * * * ** * * * * * *
* * * * * * * * * * **************** * **************** **************** *
* *
* *
************************************************************************************************************************************************************************************/
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n) for(i=0;i<(n);++i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define MAX 100002
#define PI 3.1415926535897932384626433832795
typedef long long int lli;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;
const lli INF = 0xFFFFFFFFFFFFFFFL;
const lli mod = 1000000007L;
lli T,n,i,m,j,k,in,cnt,l,sz;
vi a;
vi :: iterator it;
void SORT(vi &a)
{
lli sz=(lli)a.size();
if(sz<=1)
return;
vi b,c;
b.clear();a.reserve(sz/2+2);
c.clear();a.reserve(sz/2+2);
lli i=0;
fo(i,sz/2)
b.pb(a[i]);
while(i<sz)
{
c.pb(a[i]);
i++;
}
SORT(b);
SORT(c);
b.pb(INF);
c.pb(INF);
lli j=0,k=0,l=0;
fo(i,sz)
{
if(b[j]<c[k])
a[i]=b[j++];
else
{
while(l<sz/2&&c[k]>=b[l]+T)
l++;
cnt+=sz/2-l;
a[i]=c[k++];
}
}
}
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
scanf(" %lld %lld",&n,&k);
a.clear();a.reserve(n+4);
lli sum=0;
a.pb(0);
cnt=0;
fo(i,n)
{
scanf(" %lld",&in);
sum+=in-k;
a.pb(sum);
}
SORT(a);
cnt=n*(n+1)/2-cnt;
printf("%lld",cnt);
return 0;
}
Compilation message
vudu.cpp:25:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable:4996)
vudu.cpp:26:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/stack:200000000")
vudu.cpp: In function 'int main()':
vudu.cpp:92:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %lld %lld",&n,&k);
~~~~~^~~~~~~~~~~~~~~~~~~~
vudu.cpp:99:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %lld",&in);
~~~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
504 KB |
Output isn't correct |
2 |
Incorrect |
5 ms |
660 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
732 KB |
Output isn't correct |
4 |
Incorrect |
655 ms |
32968 KB |
Output isn't correct |
5 |
Incorrect |
390 ms |
32968 KB |
Output isn't correct |
6 |
Incorrect |
578 ms |
33256 KB |
Output isn't correct |
7 |
Incorrect |
640 ms |
34104 KB |
Output isn't correct |
8 |
Incorrect |
529 ms |
34104 KB |
Output isn't correct |
9 |
Incorrect |
665 ms |
36456 KB |
Output isn't correct |
10 |
Incorrect |
624 ms |
36456 KB |
Output isn't correct |