Submission #153515

# Submission time Handle Problem Language Result Execution time Memory
153515 2019-09-14T12:02:05 Z phpark King of Chairs (FXCUP4_chairs) C++17
17 / 100
1000 ms 10272 KB
#include "king.h"
using namespace std;
long long SendInfo(vector <int> W, vector <int> C)
{
	return 1;
}
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include "vassal.h"
using namespace std;
static multiset <int> sit;
static vector <pair<int, int>> chair;
static int N;
typedef pair <int, int> pii;
pii p;
void Init(long long B, vector <int> C)
{
	N = C.size();

	
	for (int i = 0; i < N; i++) {
		p.first = C[i];
		p.second = i;

		chair.push_back(p);
		
	}

	
	for (int i = 0; i < N; i++) {
		sit.insert(chair[i].first);

	}
}

int Maid(int w)
{
	int left = 0, right = N, mid = 0;
	auto itr = sit.lower_bound(w);
	if (itr == sit.end()) {
		
		return -1;
	}
	else {
		int ans = *itr;    //고른 의자 무게
		
		int idx = 0;   //고른 의자가 현재의자배열의 어디에 있는가
		
		while (left <= right) {
			int mid = (right + left) / 2;
			if (ans < chair[mid].first) {
				right = mid - 1;
				
			}
			else if (chair[mid].first < ans) {
				left = mid + 1;
			
			}
			else {
				idx = mid;
				break;
			}
		}
		//if (idx == 0)idx = right;
		int chair_num = chair[idx].second;    //고른 의자의 원래 배열의 인덱스
		
		


		chair.erase(chair.begin()+idx);
		sit.erase(itr);
		
		return chair_num;
	}
	
}

Compilation message

vassal.cpp: In function 'int Maid(int)':
vassal.cpp:35:27: warning: unused variable 'mid' [-Wunused-variable]
  int left = 0, right = N, mid = 0;
                           ^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 760 KB Correct
2 Correct 4 ms 760 KB Correct
3 Correct 4 ms 760 KB Correct
4 Correct 4 ms 760 KB Correct
5 Correct 4 ms 768 KB Correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 5988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 738 ms 5996 KB B = 1
2 Execution timed out 1091 ms 10272 KB Time limit exceeded
3 Halted 0 ms 0 KB -