Submission #77496

#TimeUsernameProblemLanguageResultExecution timeMemory
77496aryanc403Vudu (COCI15_vudu)C++14
0 / 140
665 ms36456 KiB
//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 (stderr)

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);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...