Submission #89962

# Submission time Handle Problem Language Result Execution time Memory
89962 2018-12-19T09:58:08 Z vex Vudu (COCI15_vudu) C++14
42 / 140
286 ms 20240 KB
#include <bits/stdc++.h>
#define maxn 1000005
#define plli pair<long long,int>
using namespace std;
 
int n;
plli a[maxn];
long long p;
 
int tree[maxn]={0};
int manji(int x)
{
    x--;
    int sol=0;
    while(x>0)
    {
        sol+=tree[x];
        x-=x&-x;
    }
    return sol;
}
void update(int x)
{
    while(x<=n)
    {
        tree[x]++;
        x+=x&-x;
    }
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 
    cin>>n;
    a[0]={0,0};
    for(int i=0;i<n;i++)
    {
        cin>>a[i+1].first;
        a[i+1].first+=a[i].first;
        a[i+1].second=i+1;
    }
    cin>>p;
 
    for(int i=0;i<=n;i++)
    {
        a[i].first-=p*a[i].second;
    }
  
    sort(a,a+n+1);
    int sol=0;
 
    for(int i=0;i<=n;i++)a[i].second++;
    for(int i=0;i<=n;i++)
    {
        sol+=manji(a[i].second);
        update(a[i].second);
    }
 
    cout<<sol<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 3 ms 636 KB Output is correct
3 Correct 3 ms 636 KB Output is correct
4 Incorrect 286 ms 19408 KB Output isn't correct
5 Incorrect 160 ms 19408 KB Output isn't correct
6 Incorrect 243 ms 19408 KB Output isn't correct
7 Incorrect 258 ms 19408 KB Output isn't correct
8 Incorrect 223 ms 19408 KB Output isn't correct
9 Incorrect 276 ms 20240 KB Output isn't correct
10 Incorrect 237 ms 20240 KB Output isn't correct