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

8-InSange #32

Merged
merged 5 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 3 additions & 1 deletion InSange/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
| 3์ฐจ์‹œ | 2024.03.19 | ํ”Œ๋กœ์ด๋“œ ์›Œ์…œ | [์•ฑ](https://www.acmicpc.net/problem/7579) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/9) |
| 4์ฐจ์‹œ | 2024.03.25 | ๋‹ค์ต์ŠคํŠธ๋ผ | [ํŒŒํ‹ฐ](https://www.acmicpc.net/problem/1238) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/15)|
| 5์ฐจ์‹œ | 2024.03.27 | DP | [RGB๊ฑฐ๋ฆฌ2](https://www.acmicpc.net/problem/17404) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)]
| 6์ฐจ์‹œ | 2024.04.01 | ์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ | [ํ–‰์„ฑ ํ„ฐ๋„](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/19)]
| 6์ฐจ์‹œ | 2024.04.01 | ์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ | [ํ–‰์„ฑ ํ„ฐ๋„](https://www.acmicpc.net/problem/2887) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/24)]
| 7์ฐจ์‹œ | 2024.04.04 | ์Šคํƒ | [๋ฌธ์ž์—ด ํญ๋ฐœ](https://www.acmicpc.net/problem/9935) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)]
| 8์ฐจ์‹œ | 2024.04.09 | ํˆฌ ํฌ์ธํ„ฐ | [๋‘ ์šฉ์•ก](https://www.acmicpc.net/problem/2470) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/28)]
=======
---
54 changes: 54 additions & 0 deletions InSange/์Šคํƒ/9935.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <iostream>

using namespace std;

string s, boom;
int blen;

void Solve()
{
cin >> s >> boom;

blen = boom.length();

string st = "";
for (char c : s)
{
st.push_back(c);

if (c == boom[blen-1] && st.size() >= blen)
{
bool flag = true;

for (int i = 0; i < blen; i++)
{
if (boom[i] != st[st.length() - blen + i])
{
flag = false;
break;
}
}

if (flag)
{
for (int i = 0; i < blen; i++)
{
st.pop_back();
}
}
}
}

if (st == "") cout << "FRULA";
else cout << st;
}

int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);

Solve();

return 0;
}
96 changes: 96 additions & 0 deletions InSange/ํˆฌํฌ์ธํ„ฐ/2470.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_VAL = 1999999999;

int N, num, minVal, aanswer, banswer;
vector<int> acid; // ๏ฟฝ๊ผบ
vector<int> basic; // ๏ฟฝ๏ฟฝ๏ฟฝโผบ

bool cmp(int a, int b)
{
return a > b;
}

void Input()
{
cin >> N;

for (int i = 0; i < N; i++)
{
cin >> num;
(num > 0) ? acid.push_back(num) : basic.push_back(num);
}

sort(acid.begin(), acid.end());
sort(basic.begin(), basic.end(), cmp);

minVal = MAX_VAL;
}

void Solve()
{
int a_index = 0;
int b_index = 0;
while (a_index < acid.size() && b_index < basic.size())
{
int anum, bnum;
anum = acid[a_index];
bnum = basic[b_index];

if (abs(anum + bnum) < minVal)
{
aanswer = anum;
banswer = bnum;
minVal = abs(anum + bnum);
}

(abs(anum) > abs(bnum)) ? b_index++ : a_index++;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์„น์‹œํ•œ ์‚ผํ•ญ ์—ฐ์‚ฐ์ž ์‚ฌ์šฉ

}

int sum;
if (acid.size() > 1)
{
sum = abs(acid[0] + acid[1]);
if (sum < minVal)
{
aanswer = acid[1];
banswer = acid[0];
}
}
if (basic.size() > 1)
{
sum = abs(basic[0] + basic[1]);
if (sum < minVal)
{
aanswer = basic[0];
banswer = basic[1];
}
}
if (acid.empty())
{
aanswer = basic[0];
banswer = basic[1];
}
if (basic.empty())
{
aanswer = acid[1];
banswer = acid[0];
}

cout << banswer << " " << aanswer;
}

int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);

Input();
Solve();

return 0;
}