/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <ctype.h>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin (),v.end()
using namespace std;
int ll, rr;
int n;
vector<pair<int, int>> a;
vector<int> ans;
int dp[10004], st, p[10004],l,r,sum,mx;
int Main()
{
sort(all(a));
l = r = 0;
sum = a[r].first;
while (l < n)
{
if (r < l)
{
r = l;
sum = a[r].first;
}
while (r + 1 < n && sum + a[r + 1].first <= rr)
{
r++;
sum += a[r].first;
}
if (sum >= ll)
mx = max(mx, r - l + 1);
sum -= a[l].first;
l++;
}
l = r = 0;
sum = a[r].first;
while (l < n)
{
if (r < l)
{
r = l;
sum = a[r].first;
}
while (r + 1 < n && sum + a[r + 1].first <= rr)
{
r++;
sum += a[r].first;
}
if (sum >= ll && r - l + 1 == mx)
{
for (int i = l; i <= r; i++)
ans.PB(a[i].second);
break;
}
sum -= a[l].first;
l++;
}
sort(all(ans));
return 0;
}
vector<int> find_subset(int L, int R, vector<int> w)
{
ll = L;
rr = R;
n = w.size();
while (!w.empty())
{
a.PB(MP(w.back(), w.size() - 1));
w.pop_back();
}
Main();
return ans;
}
#ifdef death
int main()
{
int L, R, N;
vector<int> W;
cin >> N >> L >> R;
for (int i = 0; i < N; i++)
{
W.PB(0);
cin >> W.back();
}
W = find_subset(L, R, W);
cout << W.size() << endl;
reverse(all(W));
while (!W.empty())
{
cout << W.back() << " ";
W.pop_back();
}
cout << endl;
return 0;
}
#endif
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [10..12] but it is 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
2 ms |
384 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = NO) |
5 |
Correct |
0 ms |
256 KB |
OK (n = 12, answer = YES) |
6 |
Correct |
1 ms |
384 KB |
OK (n = 12, answer = YES) |
7 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
8 |
Correct |
3 ms |
256 KB |
OK (n = 12, answer = YES) |
9 |
Correct |
2 ms |
384 KB |
OK (n = 6, answer = YES) |
10 |
Correct |
2 ms |
256 KB |
OK (n = 12, answer = YES) |
11 |
Correct |
2 ms |
256 KB |
OK (n = 100, answer = NO) |
12 |
Correct |
2 ms |
384 KB |
OK (n = 100, answer = YES) |
13 |
Correct |
2 ms |
256 KB |
OK (n = 100, answer = NO) |
14 |
Correct |
2 ms |
384 KB |
OK (n = 100, answer = YES) |
15 |
Correct |
2 ms |
384 KB |
OK (n = 100, answer = YES) |
16 |
Correct |
2 ms |
356 KB |
OK (n = 100, answer = YES) |
17 |
Correct |
2 ms |
384 KB |
OK (n = 100, answer = YES) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [10..12] but it is 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [10..12] but it is 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [10..12] but it is 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Incorrect |
2 ms |
256 KB |
sum of weights should be in [10..12] but it is 13 |
3 |
Halted |
0 ms |
0 KB |
- |