# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
220375 |
2020-04-07T18:52:45 Z |
infinite_iq |
Vudu (COCI15_vudu) |
C++14 |
|
1000 ms |
65540 KB |
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll inf=1e18;
const ld pai=acos(-1);
int N,n,p;
int a[1000009];
map<ll,int>id;
int tree[4000009];
void upd(int node,int l,int r,int k){
if(l==r){
tree[node]++;
return ;
}
if(k<=mid)upd(node*2,l,mid,k);
else upd(node*2+1,mid+1,r,k);
tree[node]=tree[node*2]+tree[node*2+1];
}
int query(int node,int l,int r,int s,int e){
if(s>r || e<l ) return 0 ;
if(s<=l && e>=r )return tree[node];
return query(node*2,l,mid,s,e)+query(node*2+1,mid+1,r,s,e);
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
scanf("%d",&p);
for(int i=1;i<=n;i++)a[i]-=p;
vll ret;
for(int i=0;i<=n;i++){
if(i)a[i]+=a[i-1];
ret.pb(a[i]);
}
sort(ret.begin(),ret.end());
N =1 ;
for(auto u:ret){
if(id[u])C;
id[u] = N ++ ;
}
for ( int i =0 ;i <= n ;i ++ ){
a[i] = id[a[i]];
}
ll ans=0;
for(int i=0;i<=n;i++){
ans+=query(1,0,N,0,a[i]);
upd(1,0,N,a[i]);
}
printf("%lld\n",ans);
}
Compilation message
vudu.cpp: In function 'int main()':
vudu.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
vudu.cpp:48:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
~~~~~^~~~~~~~~~~~
vudu.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&p);
~~~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
896 KB |
Output is correct |
2 |
Correct |
9 ms |
768 KB |
Output is correct |
3 |
Correct |
10 ms |
768 KB |
Output is correct |
4 |
Runtime error |
624 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Execution timed out |
1099 ms |
49364 KB |
Time limit exceeded |
6 |
Execution timed out |
1094 ms |
63952 KB |
Time limit exceeded |
7 |
Runtime error |
601 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Execution timed out |
1091 ms |
58064 KB |
Time limit exceeded |
9 |
Runtime error |
625 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Execution timed out |
1097 ms |
64976 KB |
Time limit exceeded |