#include "king.h"
#include <algorithm>
long long SendInfo(std::vector<int> W, std::vector<int> C) {
int N = W.size();
sort(W.begin(), W.end()); sort(C.begin(), C.end());
long long ans = 0;
int p = (int)C.size() - 1;
for (int i = (int)W.size() - 1; i >= 0; i--) {
if (p < 0) break;
if (C[p] >= W[i]) {
p--; ans++;
}
}
return ans;
}
#include "vassal.h"
#include <algorithm>
#include <utility>
#include <iostream>
long long BB;
int N, ft[100009];
std::vector<std::pair<int, int> > p;
void Init(long long B, std::vector<int> C) {
N = C.size();
BB = B;
p.push_back(std::make_pair(-1, -1));
for (int i = 0; i < N; i++)
p.push_back(std::make_pair(C[i], i));
p.push_back(std::make_pair(1000000000, N));
sort(p.begin(), p.end());
}
void up(int i)
{
while (i <= N) {
ft[i]++;
i += (i & (-i));
}
}
int sum(int i)
{
int s = 0;
while (i)
{
s += ft[i];
i -= (i & (-i));
}
return s;
}
int bs(int s, int e, int t)
{
int md = (s + e) / 2;
if (s >= e) return md;
if (sum(md) - sum(t) == md - t) return bs(md + 1, e, t);
return bs(s, md, t);
}
int Maid(int W) {
int t = (*std::lower_bound(p.begin(), p.end(), std::make_pair(W, -10))).second;
if (N - t > BB) t = N - BB;
int r = bs(t + 1, N + 1, t);
if (r == N + 1) return -1;
up(r);
return p[r].second;
}
Compilation message
king.cpp: In function 'long long int SendInfo(std::vector<int>, std::vector<int>)':
king.cpp:5:6: warning: unused variable 'N' [-Wunused-variable]
int N = W.size();
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
1056 KB |
Correct |
2 |
Correct |
10 ms |
1060 KB |
Correct |
3 |
Correct |
11 ms |
1060 KB |
Correct |
4 |
Correct |
10 ms |
1060 KB |
Correct |
5 |
Correct |
11 ms |
1056 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
83 ms |
4192 KB |
Correct |
2 |
Correct |
140 ms |
6560 KB |
Correct |
3 |
Correct |
142 ms |
6860 KB |
Correct |
4 |
Correct |
153 ms |
6592 KB |
Correct |
5 |
Correct |
151 ms |
7100 KB |
Correct |
6 |
Correct |
154 ms |
7096 KB |
Correct |
7 |
Correct |
139 ms |
6604 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
95 ms |
4200 KB |
B = 50991 |
2 |
Partially correct |
162 ms |
6560 KB |
B = 91406 |
3 |
Partially correct |
165 ms |
6984 KB |
B = 49847 |
4 |
Partially correct |
178 ms |
7104 KB |
B = 99850 |
5 |
Partially correct |
180 ms |
7096 KB |
B = 99598 |
6 |
Partially correct |
186 ms |
7100 KB |
B = 99746 |
7 |
Partially correct |
168 ms |
6860 KB |
B = 49910 |
8 |
Correct |
114 ms |
6856 KB |
Correct |