ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214947 | #3858. 货币 | Anthonyyan | 0 | 2ms | 1128kb | C++ | 2.0kb | 2024-11-24 12:01:20 | 2024-11-24 13:15:43 |
answer
#include <bits/stdc++.h>
#define int long long
#define pll pair<int, int>
#define rep(i, s, e, st) for (int i = s, __##i = e; i <= __##i; i += st)
#define per(i, s, e, st) for (int i = s, __##i = e; i <= __##i; i -= st)
#define lowbit(x) ((x) & (-(x)))
#define lc(x) ((x) << 1)
#define rc(x) (((x) << 1) | 1)
#define clr(dst, size) memset(dst, 0, (sizeof(int)) * size)
#define initval(dst, val, size) memset(dst, val, (sizeof(int)) * size)
#define cpy(from, to, size) memcpy(from, to, (sizeof(int)) * size)
#define mid(l, r) (((l) + (r)) >> 1)
#define min Min
#define max Max
#define abs Abs
#define gc getchar()
inline int read()
{
int x = 0, f = 1;
char ch = gc;
while (!isdigit(ch))
{
if (ch == '-')
f = -f;
ch = gc;
}
while (isdigit(ch))
{
x = (x << 1) + (x << 3) + (ch - '0');
ch = gc;
}
return x * f;
}
inline void write(int x)
{
if (x < 0)
putchar('-'), x = -x;
if (x / 10)
write(x / 10);
putchar('0' + x % 10);
}
template <typename T>
T Abs(T x) { return x < 0 ? -x : x; }
template <typename T, typename TT>
T Min(T x, TT y) { return x < y ? x : y; }
template <typename T, typename TT>
T Max(T x, TT y) { return x > y ? x : y; }
using namespace std;
const int MAXN = 1e5 + 10;
int coins[] = {500, 100, 50, 10, 5, 1};
int n, x;
int prices[MAXN];
int getMinCoins(int x)
{
int cnt = 0;
rep(i, 0, 5, 1)
{
cnt += x / coins[i];
x %= coins[i];
}
return cnt;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("coin.in", "r", stdin);
freopen("coin.out", "w", stdout);
#endif
n = read(), x = read();
rep(i, 0, n - 1, 1) prices[i] = read();
int minCoins = getMinCoins(x);
int ans = 0;
rep(j, 1, (1 << n) - 1, 1)
{
int tot = 0;
rep(i, 0, n - 1, 1) if (j & (1 << i))
tot += prices[i];
if (tot <= x)
{
int change = x - tot;
ans = max(ans, change / 1);
}
}
write(ans);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1128kb
input:
7 99999998 26136705 1552945 16888074 18997483 134901 24519734 19497970
output:
99865097
result:
wrong answer 1st numbers differ - expected: '11', found: '99865097'
Subtask #2:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 2ms
memory: 1128kb
input:
15 90 8 9 5 6 5 7 8 10 12 7 11 8 6 9 7
output:
85
result:
wrong answer 1st numbers differ - expected: '26', found: '85'
Subtask #3:
score: 0
Skipped
Subtask #4:
score: 0
Skipped
Subtask #5:
score: 0
Skipped