Submission #157507

# Submission time Handle Problem Language Result Execution time Memory
157507 2019-10-12T06:29:10 Z keta_tsimakuridze Arranging Shoes (IOI19_shoes) C++14
50 / 100
424 ms 343672 KB
#include<bits/stdc++.h>
using namespace std;
long long noneg,k,b[1000005],curindex,cursum,ans,n,a[1000005];
queue<long long>q[500005];
vector<long long>s;
void update(int ind,int value) {
 
	for(int i=ind; i<=n; i+=i&(-i))
		b[i]+=value;
}
 
int curs(int ind1) {
	cursum=0;
	for(int i=ind1; i>=1; i-=i&(-i))
		cursum+=b[i];
	return  cursum;
}
int count_swaps(std:: vector<int>s) {
	noneg=100005; n=s.size();
	for(k=0; k<s.size(); k++){
	a[k+1]=s[k]; }
	for(k=1;k<=n;k++)
		update(k,1);
 
	for(k=1; k<=n; k++) {
		if(q[a[k]+noneg].size()>0) {
			curindex=q[a[k]+noneg].front();
			q[a[k]+noneg].pop();
			ans+=curs(k)-curs(curindex)-1;
			if(a[k]<0) ans++;
			update(k,-1);
			update(curindex,1);
		} else q[a[k]*(-1)+noneg].push(k);
	}
	return ans;
}

Compilation message

shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:20:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(k=0; k<s.size(); k++){
           ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 347 ms 336888 KB Output is correct
2 Correct 349 ms 336960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 347 ms 336888 KB Output is correct
2 Correct 349 ms 336960 KB Output is correct
3 Correct 342 ms 336988 KB Output is correct
4 Correct 345 ms 336988 KB Output is correct
5 Correct 346 ms 337016 KB Output is correct
6 Correct 346 ms 336880 KB Output is correct
7 Correct 345 ms 336888 KB Output is correct
8 Correct 344 ms 336948 KB Output is correct
9 Correct 343 ms 336888 KB Output is correct
10 Correct 345 ms 336888 KB Output is correct
11 Correct 346 ms 336980 KB Output is correct
12 Correct 344 ms 337016 KB Output is correct
13 Correct 366 ms 336976 KB Output is correct
14 Correct 344 ms 336892 KB Output is correct
15 Correct 347 ms 336888 KB Output is correct
16 Correct 347 ms 336904 KB Output is correct
17 Correct 345 ms 336888 KB Output is correct
18 Correct 347 ms 336860 KB Output is correct
19 Correct 345 ms 337168 KB Output is correct
20 Correct 344 ms 336924 KB Output is correct
21 Correct 346 ms 336908 KB Output is correct
22 Correct 351 ms 336992 KB Output is correct
23 Correct 346 ms 336880 KB Output is correct
24 Correct 343 ms 336888 KB Output is correct
25 Correct 351 ms 336860 KB Output is correct
26 Correct 349 ms 336888 KB Output is correct
27 Correct 348 ms 336888 KB Output is correct
28 Correct 348 ms 337016 KB Output is correct
29 Correct 343 ms 336888 KB Output is correct
30 Correct 346 ms 336964 KB Output is correct
31 Correct 345 ms 336888 KB Output is correct
32 Correct 348 ms 336988 KB Output is correct
33 Correct 344 ms 336888 KB Output is correct
34 Correct 346 ms 336980 KB Output is correct
35 Correct 353 ms 336960 KB Output is correct
36 Correct 347 ms 336860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 347 ms 336888 KB Output is correct
2 Correct 349 ms 336960 KB Output is correct
3 Correct 350 ms 337048 KB Output is correct
4 Correct 345 ms 337016 KB Output is correct
5 Correct 350 ms 336988 KB Output is correct
6 Correct 347 ms 336856 KB Output is correct
7 Correct 345 ms 336892 KB Output is correct
8 Correct 346 ms 336888 KB Output is correct
9 Correct 349 ms 336896 KB Output is correct
10 Correct 349 ms 337020 KB Output is correct
11 Correct 346 ms 336940 KB Output is correct
12 Correct 345 ms 337016 KB Output is correct
13 Correct 343 ms 337012 KB Output is correct
14 Correct 345 ms 336888 KB Output is correct
15 Correct 348 ms 336992 KB Output is correct
16 Correct 344 ms 337032 KB Output is correct
17 Correct 348 ms 337072 KB Output is correct
18 Correct 350 ms 337092 KB Output is correct
19 Correct 346 ms 336988 KB Output is correct
20 Correct 373 ms 337532 KB Output is correct
21 Correct 377 ms 337468 KB Output is correct
22 Correct 388 ms 342928 KB Output is correct
23 Correct 385 ms 342988 KB Output is correct
24 Correct 386 ms 342904 KB Output is correct
25 Incorrect 408 ms 343672 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 351 ms 336936 KB Output is correct
2 Correct 346 ms 337016 KB Output is correct
3 Correct 345 ms 336940 KB Output is correct
4 Correct 345 ms 336944 KB Output is correct
5 Incorrect 424 ms 343004 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 347 ms 336888 KB Output is correct
2 Correct 349 ms 336960 KB Output is correct
3 Correct 342 ms 336988 KB Output is correct
4 Correct 345 ms 336988 KB Output is correct
5 Correct 346 ms 337016 KB Output is correct
6 Correct 346 ms 336880 KB Output is correct
7 Correct 345 ms 336888 KB Output is correct
8 Correct 344 ms 336948 KB Output is correct
9 Correct 343 ms 336888 KB Output is correct
10 Correct 345 ms 336888 KB Output is correct
11 Correct 346 ms 336980 KB Output is correct
12 Correct 344 ms 337016 KB Output is correct
13 Correct 366 ms 336976 KB Output is correct
14 Correct 344 ms 336892 KB Output is correct
15 Correct 347 ms 336888 KB Output is correct
16 Correct 347 ms 336904 KB Output is correct
17 Correct 345 ms 336888 KB Output is correct
18 Correct 347 ms 336860 KB Output is correct
19 Correct 345 ms 337168 KB Output is correct
20 Correct 344 ms 336924 KB Output is correct
21 Correct 346 ms 336908 KB Output is correct
22 Correct 351 ms 336992 KB Output is correct
23 Correct 346 ms 336880 KB Output is correct
24 Correct 343 ms 336888 KB Output is correct
25 Correct 351 ms 336860 KB Output is correct
26 Correct 349 ms 336888 KB Output is correct
27 Correct 348 ms 336888 KB Output is correct
28 Correct 348 ms 337016 KB Output is correct
29 Correct 343 ms 336888 KB Output is correct
30 Correct 346 ms 336964 KB Output is correct
31 Correct 345 ms 336888 KB Output is correct
32 Correct 348 ms 336988 KB Output is correct
33 Correct 344 ms 336888 KB Output is correct
34 Correct 346 ms 336980 KB Output is correct
35 Correct 353 ms 336960 KB Output is correct
36 Correct 347 ms 336860 KB Output is correct
37 Correct 344 ms 336948 KB Output is correct
38 Correct 371 ms 337088 KB Output is correct
39 Correct 343 ms 336940 KB Output is correct
40 Correct 343 ms 337016 KB Output is correct
41 Correct 345 ms 337140 KB Output is correct
42 Correct 346 ms 337116 KB Output is correct
43 Correct 370 ms 337148 KB Output is correct
44 Correct 347 ms 336988 KB Output is correct
45 Correct 345 ms 337016 KB Output is correct
46 Correct 343 ms 336936 KB Output is correct
47 Correct 342 ms 337016 KB Output is correct
48 Correct 350 ms 337016 KB Output is correct
49 Correct 345 ms 337016 KB Output is correct
50 Correct 346 ms 337036 KB Output is correct
51 Correct 343 ms 336976 KB Output is correct
52 Correct 377 ms 336968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 347 ms 336888 KB Output is correct
2 Correct 349 ms 336960 KB Output is correct
3 Correct 342 ms 336988 KB Output is correct
4 Correct 345 ms 336988 KB Output is correct
5 Correct 346 ms 337016 KB Output is correct
6 Correct 346 ms 336880 KB Output is correct
7 Correct 345 ms 336888 KB Output is correct
8 Correct 344 ms 336948 KB Output is correct
9 Correct 343 ms 336888 KB Output is correct
10 Correct 345 ms 336888 KB Output is correct
11 Correct 346 ms 336980 KB Output is correct
12 Correct 344 ms 337016 KB Output is correct
13 Correct 366 ms 336976 KB Output is correct
14 Correct 344 ms 336892 KB Output is correct
15 Correct 347 ms 336888 KB Output is correct
16 Correct 347 ms 336904 KB Output is correct
17 Correct 345 ms 336888 KB Output is correct
18 Correct 347 ms 336860 KB Output is correct
19 Correct 345 ms 337168 KB Output is correct
20 Correct 344 ms 336924 KB Output is correct
21 Correct 346 ms 336908 KB Output is correct
22 Correct 351 ms 336992 KB Output is correct
23 Correct 346 ms 336880 KB Output is correct
24 Correct 343 ms 336888 KB Output is correct
25 Correct 351 ms 336860 KB Output is correct
26 Correct 349 ms 336888 KB Output is correct
27 Correct 348 ms 336888 KB Output is correct
28 Correct 348 ms 337016 KB Output is correct
29 Correct 343 ms 336888 KB Output is correct
30 Correct 346 ms 336964 KB Output is correct
31 Correct 345 ms 336888 KB Output is correct
32 Correct 348 ms 336988 KB Output is correct
33 Correct 344 ms 336888 KB Output is correct
34 Correct 346 ms 336980 KB Output is correct
35 Correct 353 ms 336960 KB Output is correct
36 Correct 347 ms 336860 KB Output is correct
37 Correct 350 ms 337048 KB Output is correct
38 Correct 345 ms 337016 KB Output is correct
39 Correct 350 ms 336988 KB Output is correct
40 Correct 347 ms 336856 KB Output is correct
41 Correct 345 ms 336892 KB Output is correct
42 Correct 346 ms 336888 KB Output is correct
43 Correct 349 ms 336896 KB Output is correct
44 Correct 349 ms 337020 KB Output is correct
45 Correct 346 ms 336940 KB Output is correct
46 Correct 345 ms 337016 KB Output is correct
47 Correct 343 ms 337012 KB Output is correct
48 Correct 345 ms 336888 KB Output is correct
49 Correct 348 ms 336992 KB Output is correct
50 Correct 344 ms 337032 KB Output is correct
51 Correct 348 ms 337072 KB Output is correct
52 Correct 350 ms 337092 KB Output is correct
53 Correct 346 ms 336988 KB Output is correct
54 Correct 373 ms 337532 KB Output is correct
55 Correct 377 ms 337468 KB Output is correct
56 Correct 388 ms 342928 KB Output is correct
57 Correct 385 ms 342988 KB Output is correct
58 Correct 386 ms 342904 KB Output is correct
59 Incorrect 408 ms 343672 KB Output isn't correct
60 Halted 0 ms 0 KB -