Skip to content

Commit c211c04

Browse files
authored
Merge pull request #405 from xirc/atcoder/abc044
AtCoder/ABC044
2 parents d5b98d8 + 8aa4a5f commit c211c04

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

atcoder/abc044/A/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(0); cout.tie(0);
10+
11+
int N, K, X, Y;
12+
cin >> N >> K >> X >> Y;
13+
14+
int price = min(N, K) * X + max(0, N - K) * Y;
15+
cout << price << endl;
16+
17+
return 0;
18+
}

atcoder/abc044/B/main.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(0); cout.tie(0);
10+
11+
string w;
12+
cin >> w;
13+
14+
unordered_map<char,int> charCounter;
15+
for (auto c : w) {
16+
charCounter[c]++;
17+
}
18+
auto beautiful = true;
19+
for (auto kv : charCounter) {
20+
if (kv.second % 2 == 1) {
21+
beautiful = false;
22+
break;
23+
}
24+
}
25+
cout << (beautiful ? "Yes" : "No") << endl;
26+
27+
return 0;
28+
}

atcoder/abc044/C/main.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int N, A;
8+
vector<int> xs;
9+
10+
ll solve() {
11+
const int M = 50 * 50;
12+
vector<vector<ll>> DP(N+1, vector<ll>(M+1, 0));
13+
DP[0][0] = 1;
14+
15+
for (auto x : xs) {
16+
for (int i = N; i > 0; --i) {
17+
for (int j = M; j - x >= 0; --j) {
18+
DP[i][j] += DP[i-1][j-x];
19+
}
20+
}
21+
}
22+
23+
ll ans = 0;
24+
for (int i = 1; i <= N; ++i) {
25+
ans += DP[i][i*A];
26+
}
27+
return ans;
28+
}
29+
30+
int main() {
31+
ios_base::sync_with_stdio(false);
32+
cin.tie(0); cout.tie(0);
33+
34+
cin >> N >> A;
35+
xs.assign(N, 0);
36+
for (auto &x : xs) cin >> x;
37+
cout << solve() << endl;
38+
39+
return 0;
40+
}

0 commit comments

Comments
 (0)