# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
219227 |
2020-04-04T16:09:58 Z |
L01 |
Vudu (COCI15_vudu) |
C++17 |
|
420 ms |
20344 KB |
#include <iostream>
#include <algorithm>
using namespace std;
int tnumeros,ABI[1000006],tdiferentes,limite;
long long int anterior,tsubsecuenncias;
struct casilla
{
long long int valor;
int pos;
};
casilla numeros[1000006];
bool ordpos(casilla a,casilla b)
{
return a.pos<b.pos;
}
bool ordval(casilla a,casilla b)
{
return a.valor<b.valor;
}
void actualiza(int pos)
{
while(pos<=tnumeros)
{
ABI[pos]++;
pos+=pos&-pos;
}
}
int suma(int pos)
{
int ret=0;
while(pos>0)
{
ret+=ABI[pos];
pos-=pos&-pos;
}
return ret;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>tnumeros;
for(int i=1;i<=tnumeros;i++)
{
cin>>numeros[i].valor;
numeros[i].pos=i;
}
cin>>limite;
for(int i=1;i<=tnumeros;i++)
{
numeros[i].valor+=numeros[i-1].valor-limite;
}
sort(numeros,numeros+1+tnumeros,ordval);
for(int i=0;i<=tnumeros;i++)
{
if(i==0 or numeros[i].valor!=anterior)
{
anterior=numeros[i].valor;
numeros[i].valor=++tdiferentes;
}
else
{
numeros[i].valor=tdiferentes;
}
}
sort(numeros,numeros+1+tnumeros,ordpos);
actualiza(numeros[0].valor);
for(int i=1;i<=tnumeros;i++)
{
tsubsecuenncias+=suma(numeros[i].valor);
actualiza(numeros[i].valor);
}
cout<<tsubsecuenncias;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
7 ms |
512 KB |
Output is correct |
4 |
Correct |
406 ms |
19704 KB |
Output is correct |
5 |
Correct |
223 ms |
11128 KB |
Output is correct |
6 |
Incorrect |
369 ms |
17200 KB |
Output isn't correct |
7 |
Correct |
373 ms |
18168 KB |
Output is correct |
8 |
Correct |
320 ms |
15480 KB |
Output is correct |
9 |
Correct |
420 ms |
20344 KB |
Output is correct |
10 |
Correct |
363 ms |
17400 KB |
Output is correct |