File tree Expand file tree Collapse file tree 3 files changed +86
-0
lines changed Expand file tree Collapse file tree 3 files changed +86
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments