Submission #43961

# Submission time Handle Problem Language Result Execution time Memory
43961 2018-03-29T00:40:05 Z IvanC Kralj (COCI16_kralj) C++17
56 / 140
2000 ms 51708 KB
#include <bits/stdc++.h>
#define LSOne(S) (S & (-S))
using namespace std;
const int MAXN = 1e6 + 10;
int Dwarves[MAXN],A[MAXN],N,exibe;
set<int> Elves,Mesa;
int main(){
	scanf("%d",&N);
	for(int i = 1;i<=N;i++){
		scanf("%d",&A[i]);
		Mesa.insert(i);
	}
	for(int i = 1;i<=N;i++){
		scanf("%d",&Dwarves[i]);
	}
	for(int i = 1;i<=N;i++){
		int x;
		scanf("%d",&x);
		Elves.insert(x);
	}
	for(int vez = 1;vez<=N;vez++){
		int posicao;
		if(A[vez] <= *(Mesa.rbegin())) posicao = *Mesa.lower_bound(A[vez]);
		else posicao = *Mesa.begin();
		Mesa.erase(posicao);
		int dwarf = Dwarves[posicao];
		if((*Elves.rbegin()) < dwarf){
			Elves.erase(Elves.begin());
		}
		else{
			exibe++;
			Elves.erase(Elves.lower_bound(dwarf));
		}
		//printf("Vez %d\n",vez);
	}
	printf("%d\n",exibe);
	return 0;
}

Compilation message

kralj.cpp: In function 'int main()':
kralj.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
  ~~~~~^~~~~~~~~
kralj.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&A[i]);
   ~~~~~^~~~~~~~~~~~
kralj.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&Dwarves[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~
kralj.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1181 ms 41336 KB Output is correct
2 Correct 897 ms 41336 KB Output is correct
3 Correct 1118 ms 50212 KB Output is correct
4 Correct 1029 ms 51456 KB Output is correct
5 Incorrect 1900 ms 51456 KB Output isn't correct
6 Incorrect 1369 ms 51456 KB Output isn't correct
7 Execution timed out 2061 ms 51456 KB Time limit exceeded
8 Incorrect 1709 ms 51456 KB Output isn't correct
9 Execution timed out 2069 ms 51660 KB Time limit exceeded
10 Execution timed out 2020 ms 51708 KB Time limit exceeded