Submission #150973

#TimeUsernameProblemLanguageResultExecution timeMemory
150973baikdohyupKing of Chairs (FXCUP4_chairs)C++17
17 / 100
1127 ms8676 KiB
#include "king.h" long long SendInfo(std::vector<int> W, std::vector<int> C) { return 0; }
#include "vassal.h" #include <algorithm> #include <iostream> std::vector<std::pair<int, int>> chair; void Init(long long B, std::vector<int> C){ int N = C.size(); for (int i = 0; i < N; i++) { chair.push_back(std::pair<int,int>(C[i], i)); } } int findidx(int first, int last, int weight, int cut) { int mid; while (first <= last) { mid = (first + last) / 2; if (mid != cut && chair[mid - 1].first < weight && chair[mid].first >= weight) { return mid; } else if (chair[mid].first < weight) { first = mid + 1; } else if (chair[mid].first >= weight && mid == cut) { return mid; } else { last = mid - 1; } } return -1; } int Maid(int W){ int first = 0, last = (int)chair.size() - 1; int idx; while (1) { idx = findidx(first, last, W, first); if (idx == -1) { return -1; } if (chair[idx].second != -1) { int temp = chair[idx].second; chair[idx].second = -1; return temp; } else { first = idx + 1; } } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...