-
Notifications
You must be signed in to change notification settings - Fork 2
Part1 practice eucha #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0b3938d
52b2933
ceb2303
89c7fd6
e1c6ff7
037bf86
bf06f59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #include <stdio.h> | ||
| #include <list> | ||
| #include <string> | ||
| using namespace std; | ||
|
|
||
| int main(void) | ||
| { | ||
| char origin[100001]; | ||
| list<char> lst; | ||
| int M; | ||
|
|
||
| scanf("%s", origin); | ||
| for (int i = 0; origin[i]; i++) | ||
| lst.push_back(origin[i]); | ||
|
|
||
| scanf("%d", &M); | ||
| list<char>::iterator it = lst.end(); | ||
| while (M--) | ||
| { | ||
| char cmd; | ||
| scanf(" %c", &cmd); | ||
| if (cmd == 'L') | ||
| { | ||
| if (it != lst.begin()) | ||
| it--; | ||
| } | ||
| else if (cmd == 'D') | ||
| { | ||
| if (it != lst.end()) | ||
| it++; | ||
| } | ||
| else if (cmd == 'B') | ||
| { | ||
| if (it != lst.begin()) | ||
| { | ||
| it--; | ||
| it = lst.erase(it); | ||
| } | ||
| } | ||
| else if (cmd == 'P') | ||
| { | ||
| char c; | ||
| scanf(" %c", &c); | ||
| lst.insert(it, c); | ||
| } | ||
| } | ||
|
|
||
| string result(lst.begin(), lst.end()); | ||
| printf("%s\n", result.c_str()); | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import sys | ||
| input = sys.stdin.readline | ||
|
|
||
| origin = input().rstrip() | ||
| left_lst = list(origin) | ||
| right_lst = [] | ||
| M = int(input()) | ||
| while M > 0: | ||
| cmd = input().rstrip() | ||
| if cmd[0] == 'L': | ||
| if left_lst: | ||
| right_lst.append(left_lst.pop()) | ||
| elif cmd[0] == 'D': | ||
| if right_lst: | ||
| left_lst.append(right_lst.pop()) | ||
| elif cmd[0] == 'B': | ||
| if left_lst: | ||
| left_lst.pop() | ||
| elif cmd[0] == 'P': | ||
| left_lst.append(cmd[2]) | ||
| M -= 1 | ||
|
|
||
| print(''.join(left_lst + right_lst[::-1])) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #include <stdio.h> | ||
| #include <algorithm> | ||
| using namespace std; | ||
| typedef long long ll; | ||
|
|
||
| int main() | ||
| { | ||
| int N, K; | ||
|
|
||
| scanf("%d", &N); | ||
| scanf("%d", &K); | ||
|
|
||
| ll l = 1; | ||
| ll r = (ll)N * N; | ||
| ll ans = -1; | ||
| while (l <= r) | ||
| { | ||
| ll m = (l + r) / 2; | ||
| ll count = 0; | ||
| for (int i = 1; i <= N; i++) | ||
| count += min(m / i, (ll)N); | ||
| if (count >= K) | ||
| { | ||
| ans = m; | ||
| r = m - 1; | ||
| } | ||
| else | ||
| l = m + 1; | ||
| } | ||
| printf("%lld\n", ans); | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| N = int(input()) | ||
| K = int(input()) | ||
|
|
||
| l = 1 | ||
| r = N * N | ||
| ans = -1 | ||
| while l <= r: | ||
| m = (l + r) // 2 | ||
| count = 0 | ||
| for i in range(1, N+1): | ||
| count += min(m // i, N) | ||
| if count >= K: | ||
| ans = m | ||
| r = m - 1 | ||
| else: | ||
| l = m + 1 | ||
| print(ans) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include <algorithm> | ||
| using namespace std; | ||
|
|
||
| int main() | ||
| { | ||
| int N; | ||
| int alp_value[26] = {0, }; | ||
| char word[11]; | ||
|
|
||
| scanf("%d", &N); | ||
| while (N--) | ||
| { | ||
| scanf("%s", word); | ||
| int place_value = 1; | ||
| for (int i = strlen(word) - 1; i >= 0; i--) | ||
| { | ||
| alp_value[word[i] - 'A'] += place_value; | ||
| place_value *= 10; | ||
| } | ||
| } | ||
|
|
||
| sort(alp_value, alp_value + 26); | ||
|
|
||
| int ans = 0; | ||
| for (int i = 0; i < 10; i++) | ||
| ans += alp_value[25 - i] * (9 - i); | ||
| printf("%d\n", ans); | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| N = int(input()) | ||
| alp_value = [0] * 26 | ||
|
|
||
| for _ in range(N): | ||
| word = input() | ||
| place_value = 1 | ||
| for i in range(len(word)-1, -1, -1): | ||
| alp_value[ord(word[i]) - ord('A')] += place_value | ||
| place_value *= 10 | ||
|
|
||
| alp_value = sorted(alp_value) | ||
|
|
||
| ans = 0 | ||
| for i in range(10): | ||
| ans += alp_value[25 - i] * (9 - i) | ||
|
|
||
| print(ans) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #include <stdio.h> | ||
| #include <vector> | ||
| #include <algorithm> | ||
| using namespace std; | ||
|
|
||
| struct student { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 우리 struct 이름 첫 글자는 대문자로 하기로 했었나? |
||
| int number; | ||
| int scr; | ||
| int posted_at; | ||
| }; | ||
|
|
||
| int main() | ||
| { | ||
| int N, R; | ||
| vector<student> post; | ||
|
|
||
| scanf("%d", &N); | ||
| scanf("%d", &R); | ||
| for (int i = 0; i < R; i++) | ||
| { | ||
| int voted_number; | ||
| scanf("%d", &voted_number); | ||
|
|
||
| bool already_posted = false; | ||
| for (int j = 0; j < post.size(); j++) | ||
| { | ||
| if (post[j].number == voted_number) | ||
| { | ||
| post[j].scr++; | ||
| already_posted = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (!already_posted) | ||
| { | ||
| if (post.size() < N) | ||
| post.push_back({voted_number, 1, i}); | ||
| else | ||
| { | ||
| sort(post.begin(), post.end(), [](student o1, student o2)->bool{ return o1.scr == o2.scr ? o1.posted_at < o2.posted_at : o1.scr < o2.scr; }); | ||
| post[0] = {voted_number, 1, i}; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| sort(post.begin(), post.end(), [](student o1, student o2)->bool{ return o1.number < o2.number; }); | ||
| for (int i = 0; i < post.size(); i++) | ||
| printf("%d ", post[i]); | ||
| printf("\n"); | ||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| class student: | ||
| def __init__(self, number, scr, posted_at): | ||
| self.number = number | ||
| self.scr = scr | ||
| self.posted_at = posted_at | ||
|
|
||
| N = int(input()) | ||
| R = int(input()) | ||
| voted_number_list = list(map(int,input().split())) | ||
| post = [] | ||
|
|
||
| for i in range(R): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 나는 뭔가 |
||
| already_posted = False | ||
|
|
||
| for j in range(len(post)): | ||
| if post[j].number == voted_number_list[i]: | ||
| post[j].scr += 1 | ||
| already_posted = True | ||
| break | ||
|
|
||
| if not already_posted: | ||
| if len(post) < N: | ||
| post.insert(0, student(voted_number_list[i], 1, i)) | ||
| else: | ||
| post.sort(key=lambda s: (s.scr, s.posted_at)) | ||
| post[0] = student(voted_number_list[i], 1, i) | ||
|
|
||
| post.sort(key=lambda s: s.number) | ||
| print(' '.join(str(s.number) for s in post)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #include <stdio.h> | ||
| #include <string> | ||
| #include <algorithm> | ||
| using namespace std; | ||
|
|
||
| int main() | ||
| { | ||
| int k; | ||
| string ans; | ||
|
|
||
| scanf("%d", &k); | ||
|
|
||
| k++; | ||
| while (k) | ||
| { | ||
| if (k % 2 == 0) | ||
| ans.push_back('4'); | ||
| else | ||
| ans.push_back('7'); | ||
| k /= 2; | ||
| } | ||
| reverse(ans.begin(), ans.end()); | ||
|
|
||
| printf("%s\n", ans.c_str() + 1); | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| K = int(input()) | ||
|
|
||
| ans = str(bin(K + 1))[3:].replace('0', '4').replace('1', '7') | ||
|
|
||
| print(ans) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #include <stdio.h> | ||
| #include <vector> | ||
| #include <algorithm> | ||
| using namespace std; | ||
| typedef long long ll; | ||
|
|
||
| ll how_many_pass(ll given_time, vector<int> &time_per_pass) | ||
| { | ||
| ll count = 0; | ||
| for (int i = 0; i < time_per_pass.size(); i++) | ||
| count += given_time / time_per_pass[i]; | ||
| return count; | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| int N, M; | ||
|
|
||
| scanf("%d %d", &N, &M); | ||
| vector<int> time_per_pass(N); | ||
| for (int i = 0; i < N; i++) | ||
| scanf("%d", &time_per_pass[i]); | ||
|
|
||
| ll ans; | ||
| ll l = 1; | ||
| ll r = (ll)(*min_element(time_per_pass.begin(), time_per_pass.end())) * M; | ||
| while (l <= r) | ||
| { | ||
| ll m = (l + r) / 2; | ||
| if (how_many_pass(m, time_per_pass) >= M) | ||
| { | ||
| ans = m; | ||
| r = m - 1; | ||
| } | ||
| else | ||
| l = m + 1; | ||
| } | ||
| printf("%lld\n", ans); | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||||
| def how_many_pass(given_time, time_per_pass): | ||||||||||||||||
| count = 0 | ||||||||||||||||
| for t in time_per_pass: | ||||||||||||||||
| count += given_time // t | ||||||||||||||||
| return count | ||||||||||||||||
|
Comment on lines
+1
to
+5
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이런건 괜찮나?
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| N, M = map(int, input().split()) | ||||||||||||||||
|
|
||||||||||||||||
| time_per_pass = [int(input()) for _ in range(N)] | ||||||||||||||||
|
|
||||||||||||||||
| ans = 0 | ||||||||||||||||
| l = 1 | ||||||||||||||||
| r = min(time_per_pass) * M | ||||||||||||||||
|
|
||||||||||||||||
| while l <= r: | ||||||||||||||||
| m = (l + r) // 2 | ||||||||||||||||
| if how_many_pass(m, time_per_pass) >= M: | ||||||||||||||||
| ans = m | ||||||||||||||||
| r = m - 1 | ||||||||||||||||
| else: | ||||||||||||||||
| l = m + 1 | ||||||||||||||||
|
|
||||||||||||||||
| print(ans) | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.