Skip to content
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

17-oesnuj #52

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions oesnuj/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
| 13μ°¨μ‹œ | 2024.07.28 | DP | [λΆ€λ…€νšŒμž₯이 λ ν…Œμ•Ό](https://www.acmicpc.net/problem/2775) | [#44](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/44) |
| 14μ°¨μ‹œ | 2024.08.05 | ν•΄μ‹œ | [ λ‚˜λŠ”μ•Ό 포켓λͺ¬ λ§ˆμŠ€ν„° μ΄λ‹€μ†œ ](https://www.acmicpc.net/problem/1620) | [#46](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/46) |
| 15μ°¨μ‹œ | 2024.08.10 | 그리디 | [ 주식 ](https://www.acmicpc.net/problem/11501) | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/47) |
| 16μ°¨μ‹œ | 2024.09.13 | κ΅¬ν˜„ | [ 달λ ₯ ](https://www.acmicpc.net/problem/20207) | [#50](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/50) |
| 17μ°¨μ‹œ | 2024.09.21 | κ΅¬ν˜„ | [ 큰 수 A+B(2) ](https://www.acmicpc.net/problem/15353) | [#52](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/52) |
---
34 changes: 34 additions & 0 deletions oesnuj/κ΅¬ν˜„/15353.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string Add(string str1, string str2)
{
string result = "";
int i = str1.size() - 1;
int j = str2.size() - 1;
int carry = 0;
while (i >= 0 || j >= 0 || carry > 0)
{
int num1 = 0, num2 = 0;
if (i >= 0)
num1 = str1[i--] - '0';
if (j >= 0)
num2 = str2[j--] - '0';

int sum = num1 + num2 + carry;
carry = sum / 10;
result = to_string(sum % 10) + result;
}
return result;
}

int main()
{
string a, b;
cin >> a >> b;
cout << Add(a, b);
return 0;
}
42 changes: 42 additions & 0 deletions oesnuj/κ΅¬ν˜„/20207.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <iostream>
#include <vector>
using namespace std;

struct EventPeriod
{
int start, end;
};

int main()
{
int N;
cin >> N;
vector <EventPeriod> v(N);
int days[365] = {0};

for(int i = 0; i < N; i++)
{
cin >> v[i].start >> v[i].end; //일정 μ‹œμž‘μΌ, μ’…λ£ŒμΌ μž…λ ₯λ°›κΈ°

for (int k = v[i].start - 1; k < v[i].end; k++) {
days[k]++; //일정에 ν¬ν•¨λ˜λŠ” λ‚ μ˜ λ°°μ—΄ κ°’ +1;
}
}

int result = 0;
int height = 0, width = 0;
for (int i = 0; i < 365; i++) {
if (days[i] != 0) {
width++;
height = max(height, days[i]);
}

if (days[i + 1] == 0) {
result += height * width;
width = 0;
height = 0;
}
}
cout << result;
return 0;
}