#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define OPT ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define bpc __builtin_popcount
#define print(v) for(int i = 0; i < v.size(); i++) \
cout << v[i] << " "; \
cout<<endl;
int main()
{
int n, L;
cin >> n >> L;
set<pii> s;
int y = 0;
for (int i = -n; i <= n; i++)
{
int x;
cin >> x;
if (i == 0)
{
y = x;
continue;
}
set<pii> temp;
for (int k = 1; k <= x; k++)
{
for (pii f : s)
{
temp.insert(mpr(f.fi + k * i, f.se + k));
}
}
for (int k = 1; k <= x; k++)
{
s.insert(mpr(k * i, k));
}
s.insert(temp.begin(), temp.end());
}
if (L == 0)
{
cout << y << endl;
return 0;
}
auto it = s.upper_bound(mpr(L, inf));
it--;
if ((*it).fi == L) cout << (*it).se + y << endl;
else cout << "impossible\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
6 ms |
596 KB |
Output is correct |
5 |
Execution timed out |
5081 ms |
30960 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
6 ms |
596 KB |
Output is correct |
5 |
Execution timed out |
5081 ms |
30960 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
660 KB |
Output is correct |
2 |
Execution timed out |
5076 ms |
31336 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
660 KB |
Output is correct |
2 |
Execution timed out |
5076 ms |
31336 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
660 KB |
Output is correct |
2 |
Execution timed out |
5076 ms |
31336 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
6 ms |
596 KB |
Output is correct |
5 |
Execution timed out |
5081 ms |
30960 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
660 KB |
Output is correct |
2 |
Execution timed out |
5076 ms |
31336 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
6 ms |
596 KB |
Output is correct |
5 |
Execution timed out |
5081 ms |
30960 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
660 KB |
Output is correct |
2 |
Execution timed out |
5076 ms |
31336 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
6 ms |
596 KB |
Output is correct |
5 |
Execution timed out |
5081 ms |
30960 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |