Submission #56139

# Submission time Handle Problem Language Result Execution time Memory
56139 2018-07-10T05:48:05 Z 김세빈(#1581) Swap (BOI16_swap) C++11
0 / 100
8 ms 6648 KB
#include <bits/stdc++.h>

using namespace std;

priority_queue <int, vector <int>, greater <int> > Q[202020];
int A[202020], K[202020];
int n;

int main()
{
	int i, a, b, c;
	
	scanf("%d", &n);
	
	for(i=1;i<=n;i++){
		scanf("%d", A+i);
		K[i] = i;
		Q[i].push(A[i]);
	}
	
	for(i=1;i<=n;i++){
		a = Q[K[i]].top();
		b = (i<<1) <= n? Q[i<<1].top() : 1e9;
		c = (i<<1|1) <= n? Q[i<<1|1].top() : 1e9;
		
		if(a < b && a < c){
			printf("%d ", a);
			Q[K[i]].pop();
		}
		else if(b < c){
			printf("%d ", b);
			Q[K[i]].push(A[i<<1|1]);
			K[i<<1] = K[i<<1|1] = K[i];
		}
		else{
			printf("%d ", c);
			Q[K[i]].push(A[i<<1]);
			K[i<<1] = K[i<<1|1] = K[i];
		}
	}
	
	printf("\n");
	
	return 0;
}

Compilation message

swap.cpp: In function 'int main()':
swap.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
swap.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", A+i);
   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 6648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 6648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 6648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 6648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 6648 KB Output isn't correct
2 Halted 0 ms 0 KB -