This repository was archived by the owner on Feb 22, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +130
-2
lines changed Expand file tree Collapse file tree 3 files changed +130
-2
lines changed Original file line number Diff line number Diff line change 133
133
- [X] ** 17276_배열 돌리기** / [ 문제] ( https://www.acmicpc.net/problem/17276 ) / [ 풀이] ( )
134
134
- [X] ** 20207_달력** / [ 문제] ( https://www.acmicpc.net/problem/20207 ) / [ 풀이] ( )
135
135
- [X] ** 21608_상어 초등학교** / [ 문제] ( https://www.acmicpc.net/problem/21608 ) / [ 풀이] ( )
136
- - [ ] ** 20164_홀수 홀릭 호석** / [ 문제] ( https://www.acmicpc.net/problem/20164 ) / [ 풀이] ( )
137
- - [ ] ** 1419_빗물** / [ 문제] ( https://www.acmicpc.net/problem/14719 ) / [ 풀이] ( )
136
+ - [X ] ** 20164_홀수 홀릭 호석** / [ 문제] ( https://www.acmicpc.net/problem/20164 ) / [ 풀이] ( )
137
+ - [X ] ** 1419_빗물** / [ 문제] ( https://www.acmicpc.net/problem/14719 ) / [ 풀이] ( )
138
138
- [ ] ** 16719_ZOAC** / [ 문제] ( https://www.acmicpc.net/problem/16719 ) / [ 풀이] ( )
139
139
140
140
---
Original file line number Diff line number Diff line change
1
+ /*
2
+ # Implementation
3
+ # Problem: 14710
4
+ # Memory: 2024KB
5
+ # Time: 0ms
6
+ */
7
+ #include < iostream>
8
+ #include < vector>
9
+ #include < cmath>
10
+ #include < string>
11
+ #include < string.h>
12
+ using namespace std ;
13
+
14
+ #define MAX 500
15
+
16
+ int W, H;
17
+ int arr[MAX] = {0 ,};
18
+ int res[MAX] = {0 ,};
19
+
20
+ int main (void ) {
21
+ cin.tie (NULL );
22
+ ios::sync_with_stdio (false );
23
+
24
+ cin>> H >> W;
25
+ for (int i = 0 ; i < W; i++)
26
+ cin >> arr[i];
27
+
28
+ for (int i = 0 ; i < W; i++) // =>
29
+ for (int j = i+1 ; j < W; j++)
30
+ if (arr[i] <= arr[j]){
31
+ for (int k = i+1 ; k < j; k++)
32
+ res[k] = max (res[k], arr[i] - arr[k]);
33
+ break ;
34
+ }
35
+
36
+
37
+ for (int i = W; i >= 0 ; i--) // <=
38
+ for (int j = i-1 ; j >=0 ; j--)
39
+ if (arr[i] <= arr[j]){
40
+ for (int k = i-1 ; k > j; k--)
41
+ res[k] = max (res[k], arr[i] - arr[k]);
42
+ break ;
43
+ }
44
+
45
+ int result = 0 ;
46
+ for (int i = 0 ; i < W; i++)
47
+ result+=res[i];
48
+ cout << result <<' \n ' ;
49
+
50
+ return 0 ;
51
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ # Implementation
3
+ # Problem: 20164
4
+ # Memory: 2028KB
5
+ # Time: 0ms
6
+ */
7
+ #include < iostream>
8
+ #include < vector>
9
+ #include < cmath>
10
+ #include < string>
11
+ #include < string.h>
12
+ using namespace std ;
13
+
14
+ string s;
15
+ #define INF 1e9
16
+ int min_val = INF, max_val = 0 ;
17
+
18
+
19
+ // count odd num in str
20
+ int odd_count (string str){
21
+ int n = 0 ;
22
+ int s_size = str.size ();
23
+ for (int i = 0 ; i < s_size; i++)
24
+ if (str[i] % 2 == 1 )
25
+ n++;
26
+ return n;
27
+ }
28
+
29
+ // update min, max value
30
+ void updater (int num){
31
+ min_val = min (min_val, num);
32
+ max_val = max (max_val, num);
33
+ }
34
+
35
+ // recursively make str
36
+ void func (string str, int cur_odd){
37
+ /* 1 */
38
+ cur_odd = cur_odd + odd_count (str+' 0' );
39
+
40
+ int N = str.size ();
41
+ if (N == 1 ) { /* 2 */
42
+ updater (cur_odd);
43
+ }
44
+ else if (N == 2 ){ /* 3 */
45
+ int a = str[0 ] - ' 0' ;
46
+ int b = str[1 ] - ' 0' ;
47
+ str = to_string (a+b);
48
+
49
+ func (str, cur_odd);
50
+
51
+ }else { /* 4 */
52
+ for (int i = 1 ; i < N-1 ; i++){
53
+ for (int j = i+1 ; j < N; j++){
54
+ int a = stoi (str.substr (0 , i));
55
+ int b = stoi (str.substr (i, j-i));
56
+ int c = stoi (str.substr (j, N-j));
57
+ string tmp_s = to_string (a + b + c);
58
+
59
+ func (tmp_s, cur_odd);
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ int main (void ) {
66
+ cin.tie (NULL );
67
+ ios::sync_with_stdio (false );
68
+
69
+ cin >> s;
70
+ func (s, 0 );
71
+
72
+ cout<< min_val << ' ' << max_val << ' \n ' ;
73
+ return 0 ;
74
+ }
75
+
76
+ // substr(pos, cnt)
77
+ // [pos, pos + cnt)
You can’t perform that action at this time.
0 commit comments