Submission #151647

# Submission time Handle Problem Language Result Execution time Memory
151647 2019-09-04T03:02:18 Z rose0310 King of Chairs (FXCUP4_chairs) C++17
0 / 100
1000 ms 3232 KB
#include "king.h"
#include<algorithm>
#include<iostream>
using namespace std;

long long SendInfo(std::vector<int> W, std::vector<int> C) {
	int N = W.size();
	long long upper = 0;
	sort(W.begin(), W.end());
	sort(C.begin(), C.end());
	int cnt = 0;
	for (auto i : W) {
		while (cnt<N-1 && i > C[cnt]) cnt++;
		if(i<=C[cnt])upper = i;
	}
	return upper;
}
#include "vassal.h"
#include<algorithm>
#include<iostream>
using namespace std;

long long BB;
std::vector<int>CC;
void Init(long long B, std::vector<int> C){
	int N = C.size();
	BB = B;
	CC= C;
	sort(CC.begin(), CC.end());
}
bool v[101010];
int Maid(int W){
	if (BB < W) return -1;
	
	int l=0, r=CC.size()-1, mid;
	while (l < r) {
		mid = (l + r+1) / 2;
		if (CC[mid] < W) l = mid + 1;
		else r = mid;
	}
	while (r+1<CC.size() && v[r]) r++;
	v[r] = 1;
	return r;
}

Compilation message

vassal.cpp: In function 'void Init(long long int, std::vector<int>)':
vassal.cpp:9:6: warning: unused variable 'N' [-Wunused-variable]
  int N = C.size();
      ^
vassal.cpp: In function 'int Maid(int)':
vassal.cpp:24:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (r+1<CC.size() && v[r]) r++;
         ~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 18 ms 760 KB Correct
2 Execution timed out 1074 ms 744 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 3192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1158 ms 3232 KB Time limit exceeded
2 Halted 0 ms 0 KB -