이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int N;
cin >> N;
vector<int> X;
for (int i = 0; i < N; i++) {
int Xi;
cin >> Xi;
X.push_back(Xi);
}
vector<int> L;
for (int i = 0; i < N; i++) {
int Li;
cin >> Li;
L.push_back(Li);
}
if (N > 10) {
int ans = 0;
sort(X.begin(),X.end());
ll currLevel = 0;
ll cap = L.back();
vector<int>::iterator p = X.begin();
while ((currLevel <= cap)&&(p!=X.end())) {
ans++;
currLevel += *p;
p++;
}
cout << ans << endl;
} else {
int ans = 0;
vector<pair<int,int>> pq;
for (int i = 0; i < N; i++) {
pq.push_back(make_pair(X[i],L[i]));
}
sort(pq.begin(),pq.end());
for(int i = 0; i < N; i++) {
int currAns = 0;
ll currLevel = 0;
for (int j = i; j < N; j++) {
if (currLevel > pq[j].second) {
j++;
} else {
currAns++;
currLevel += pq[j].first;
}
}
ans = max(ans,currAns);
}
cout << ans << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |