#include "king.h"
#include <algorithm>
long long SendInfo(std::vector<int> W, std::vector<int> C) {
sort(W.begin(), W.end());
sort(C.begin(), C.end());
int last = 0;
long long ans = 0;
for(int w : W)
{
while(last < C.size() && w > C[last]) last++;
if(last < C.size() && w <= C[last]) ans = w;
}
return ans;
}
#include "vassal.h"
#include <algorithm>
#include <utility>
typedef std::pair<int, int> pii;
long long BB;
std::vector<pii> CC;
bool isSeated[1100000];
void Init(long long B, std::vector<int> C){
int N = C.size();
BB = B;
for(int i = 0; i < N; i++)
CC.emplace_back(C[i], i);
sort(CC.begin(), CC.end());
}
int Maid(int W) {
if(W > BB) return -1;
auto it = lower_bound(CC.begin(), CC.end(), pii(W, -1));
int pos = it->second;
while(isSeated[pos]) pos++;
isSeated[pos] = true;
if(pos >= CC.size()) return -1;
return pos;
}
Compilation message
king.cpp: In function 'long long int SendInfo(std::vector<int>, std::vector<int>)':
king.cpp:11:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(last < C.size() && w > C[last]) last++;
~~~~~^~~~~~~~~~
king.cpp:12:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(last < C.size() && w <= C[last]) ans = w;
~~~~~^~~~~~~~~~
vassal.cpp: In function 'int Maid(int)':
vassal.cpp:23:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(pos >= CC.size()) return -1;
~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
876 KB |
Correct |
2 |
Correct |
4 ms |
632 KB |
Correct |
3 |
Correct |
4 ms |
636 KB |
Correct |
4 |
Correct |
4 ms |
764 KB |
Correct |
5 |
Correct |
4 ms |
764 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
3752 KB |
Correct |
2 |
Correct |
96 ms |
8764 KB |
Correct |
3 |
Execution timed out |
1032 ms |
9504 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
59 ms |
3788 KB |
B = 999992 |
2 |
Partially correct |
114 ms |
8788 KB |
B = 999980 |
3 |
Execution timed out |
1063 ms |
9384 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |