Submission #1174

# Submission time Handle Problem Language Result Execution time Memory
1174 2013-06-28T14:26:08 Z kriii 공장 (KOI13_factory) C++
20 / 20
265 ms 8696 KB
#include <stdio.h>

int N,V[1000010],B[1000010];
long long ans;

int main()
{
	int i,x,u;

	scanf ("%d",&N);
	for (i=1;i<=N;i++){
		scanf ("%d",&x);
		V[x] = i;
	}

	for (i=1;i<=N;i++){
		scanf ("%d",&x); x = N - V[x] + 1;
		for (u=x;u;u-=u&(-u)) ans += B[u];
		for (u=x;u<=N;u+=u&(-u)) B[u]++;
	}

	printf ("%lld\n",ans);

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 8696 KB Output is correct
2 Correct 0 ms 8696 KB Output is correct
3 Correct 0 ms 8696 KB Output is correct
4 Correct 0 ms 8696 KB Output is correct
5 Correct 0 ms 8696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 8696 KB Output is correct
2 Correct 0 ms 8696 KB Output is correct
3 Correct 3 ms 8696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 8696 KB Output is correct
2 Correct 26 ms 8696 KB Output is correct
3 Correct 35 ms 8696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 8696 KB Output is correct
2 Correct 77 ms 8696 KB Output is correct
3 Correct 99 ms 8696 KB Output is correct
4 Correct 152 ms 8696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 212 ms 8696 KB Output is correct
2 Correct 226 ms 8696 KB Output is correct
3 Correct 234 ms 8696 KB Output is correct
4 Correct 265 ms 8696 KB Output is correct
5 Correct 260 ms 8696 KB Output is correct
6 Correct 260 ms 8696 KB Output is correct