-
Notifications
You must be signed in to change notification settings - Fork 2
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
64-9kyo-hwang #221
Merged
Merged
64-9kyo-hwang #221
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1f9f82f
58-9kyo-hwang
9kyo-hwang 91fa21c
59-9kyo-hwang
9kyo-hwang 30b109d
[60-9kyo-hwang]
9kyo-hwang 9208996
61-9kyo-hwang
9kyo-hwang f754cc5
62-9kyo-hwang
9kyo-hwang abe7706
63-9kyo-hwang
9kyo-hwang b9a906d
64-9kyo-hwang
9kyo-hwang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
cin.tie(nullptr)->sync_with_stdio(false); | ||
|
||
int N, M; cin >> N >> M; | ||
|
||
vector<int> Nums(N); | ||
for(int& Num : Nums) | ||
{ | ||
cin >> Num; | ||
} | ||
|
||
auto IsValid = [&](int EstimateScore) | ||
{ | ||
int Count = 1; | ||
int Min = Nums[0], Max = Nums[0]; | ||
|
||
for(int i = 1; i < N; ++i) | ||
{ | ||
Min = min(Min, Nums[i]); | ||
Max = max(Max, Nums[i]); | ||
|
||
if(Max - Min > EstimateScore) | ||
{ | ||
Count++; | ||
Min = Nums[i]; | ||
Max = Nums[i]; | ||
} | ||
} | ||
|
||
return Count <= M; | ||
}; | ||
|
||
int Min = 0, Max = *max_element(Nums.begin(), Nums.end()); | ||
int Score = Max; | ||
while(Min <= Max) | ||
{ | ||
int EstimateScore = (Min + Max) / 2; | ||
if(IsValid(EstimateScore)) | ||
{ | ||
Score = min(Score, EstimateScore); | ||
Max = EstimateScore - 1; | ||
} | ||
else | ||
{ | ||
Min = EstimateScore + 1; | ||
} | ||
} | ||
|
||
cout << Score; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int solution(int InDistance, vector<int> InRocks, int NumRemove) | ||
{ | ||
InRocks.emplace_back(InDistance); | ||
sort(InRocks.begin(), InRocks.end()); | ||
|
||
int LowerDistance = 1, UpperDistance = InDistance; | ||
int Answer = 0; | ||
|
||
auto IsValid = [&](int EstimateDistance) | ||
{ | ||
int Count = 0, CurrentPos = 0; | ||
for(int RockPos : InRocks) | ||
{ | ||
int Distance = RockPos - CurrentPos; | ||
if(Distance >= EstimateDistance) | ||
{ | ||
CurrentPos = RockPos; | ||
} | ||
else | ||
{ | ||
Count++; | ||
} | ||
} | ||
|
||
return Count <= NumRemove; | ||
}; | ||
|
||
while(LowerDistance <= UpperDistance) | ||
{ | ||
int EstimateDistance = (LowerDistance + UpperDistance) / 2; | ||
if(IsValid(EstimateDistance)) | ||
{ | ||
Answer = EstimateDistance; | ||
LowerDistance = EstimateDistance + 1; | ||
} | ||
else | ||
{ | ||
UpperDistance = EstimateDistance - 1; | ||
} | ||
} | ||
|
||
return Answer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int Merge(vector<string>& Maps, int x, int y) | ||
{ | ||
if(x < 0 || x >= Maps.size() || y < 0 || y >= Maps[0].size() || Maps[x][y] == 'X') | ||
{ | ||
return 0; | ||
} | ||
|
||
int Day = Maps[x][y] - '0'; | ||
Maps[x][y] = 'X'; | ||
|
||
return Day | ||
+ Merge(Maps, x - 1, y) | ||
+ Merge(Maps, x, y + 1) | ||
+ Merge(Maps, x + 1, y) | ||
+ Merge(Maps, x, y - 1); | ||
} | ||
|
||
vector<int> solution(vector<string> Maps) | ||
{ | ||
vector<int> DaysofStay; | ||
for(int i = 0; i < Maps.size(); ++i) | ||
{ | ||
for(int j = 0; j < Maps[0].size(); ++j) | ||
{ | ||
if(Maps[i][j] != 'X') | ||
{ | ||
DaysofStay.emplace_back(Merge(Maps, i, j)); | ||
} | ||
} | ||
} | ||
|
||
if(DaysofStay.empty()) | ||
{ | ||
return {-1}; | ||
} | ||
|
||
sort(DaysofStay.begin(), DaysofStay.end()); | ||
return DaysofStay; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <vector> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
int solution(int Storey) | ||
{ | ||
int Answer = 0; | ||
|
||
while(Storey) | ||
{ | ||
int Remainder = Storey % 10; | ||
int Quotient = Storey / 10; | ||
|
||
if(Remainder < 5) // ์: 54 | ||
{ | ||
Answer += Remainder; // 54 -> 50 | ||
} | ||
else if(Remainder > 5) // ์: 16 | ||
{ | ||
++Quotient; | ||
Answer += 10 - Remainder; // 16 -> 20 | ||
} | ||
else | ||
{ | ||
if(Quotient % 10 >= 5) // ์: 55 -> 60 / 25 -> 20 | ||
{ | ||
++Quotient; | ||
} | ||
|
||
Answer += Remainder; | ||
} | ||
|
||
Storey = Quotient; | ||
} | ||
|
||
return Answer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
struct FPlan | ||
{ | ||
string Name; | ||
int Start; | ||
int Playtime; | ||
|
||
FPlan() {} | ||
FPlan(const string& InName, const string& InStart, const string& InPlaytime) | ||
{ | ||
Name = InName; | ||
Start = stoi(InStart.substr(0, 2)) * 60 + stoi(InStart.substr(3, 2)); | ||
Playtime = stoi(InPlaytime); | ||
} | ||
|
||
const bool operator<(const FPlan& Rhs) const | ||
{ | ||
return Start < Rhs.Start; | ||
} | ||
}; | ||
|
||
vector<string> solution(vector<vector<string>> InPlans) | ||
{ | ||
vector<FPlan> Plans; | ||
for(const vector<string>& Plan : InPlans) | ||
{ | ||
Plans.push_back({Plan[0], Plan[1], Plan[2]}); | ||
} | ||
|
||
sort(Plans.begin(), Plans.end()); | ||
|
||
vector<string> Result; | ||
vector<int> Paused; | ||
|
||
for(int i = 0; i < Plans.size() - 1; ++i) | ||
{ | ||
int TimeDifference = Plans[i + 1].Start - Plans[i].Start; | ||
if(Plans[i].Playtime > TimeDifference) | ||
{ | ||
Plans[i].Playtime -= TimeDifference; | ||
Paused.emplace_back(i); | ||
continue; | ||
} | ||
|
||
TimeDifference -= Plans[i].Playtime; | ||
Plans[i].Playtime = 0; | ||
Result.emplace_back(Plans[i].Name); | ||
|
||
while(TimeDifference > 0 && !Paused.empty()) | ||
{ | ||
int Index = Paused.back(); | ||
if(Plans[Index].Playtime > TimeDifference) | ||
{ | ||
Plans[Index].Playtime -= TimeDifference; | ||
break; | ||
} | ||
|
||
TimeDifference -= Plans[Index].Playtime; | ||
Plans[Index].Playtime = 0; | ||
Result.emplace_back(Plans[Index].Name); | ||
Paused.pop_back(); | ||
} | ||
} | ||
|
||
Result.emplace_back(Plans.back().Name); | ||
|
||
while(!Paused.empty()) | ||
{ | ||
Result.emplace_back(Plans[Paused.back()].Name); | ||
Paused.pop_back(); | ||
} | ||
|
||
return Result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int solution(vector<vector<int>> Data, int Col, int RowBegin, int RowEnd) | ||
{ | ||
sort(Data.begin(), Data.end(), [&](const auto& Lhs, const auto& Rhs) | ||
{ | ||
return Lhs[Col - 1] == Rhs[Col - 1] ? Lhs[0] > Rhs[0] : Lhs[Col - 1] < Rhs[Col - 1]; | ||
}); | ||
|
||
int HashVal = 0; | ||
for(int i = RowBegin; i <= RowEnd; ++i) | ||
{ | ||
int S_i = 0; | ||
for(const int Val : Data[i - 1]) | ||
{ | ||
S_i += Val % i; | ||
} | ||
HashVal ^= S_i; | ||
} | ||
|
||
return HashVal; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <map> | ||
|
||
using namespace std; | ||
|
||
struct FNode | ||
{ | ||
map<string, FNode*> Node; | ||
}; | ||
|
||
FNode* Root; | ||
|
||
void Print(FNode* InNode = Root, const string& Prefix="") | ||
{ | ||
if(InNode == nullptr) | ||
{ | ||
return; | ||
} | ||
|
||
for(const auto& [Data, Next] : InNode->Node) | ||
{ | ||
cout << Prefix << Data << "\n"; | ||
Print(Next, Prefix + "--"); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
cin.tie(nullptr)->sync_with_stdio(false); | ||
|
||
Root = new FNode(); | ||
|
||
int N; cin >> N; | ||
for(int n = 0; n < N; ++n) | ||
{ | ||
FNode* Ptr = Root; | ||
|
||
int K; cin >> K; | ||
for(int k = 0; k < K; ++k) | ||
{ | ||
string Info; cin >> Info; | ||
if(Ptr->Node.count(Info) == 0) | ||
{ | ||
Ptr->Node[Info] = new FNode(); | ||
} | ||
|
||
Ptr = Ptr->Node[Info]; | ||
} | ||
} | ||
|
||
Print(); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
์ ๋ ์ด ํ ์ค ๋๋ฌธ์ ํ์ฐธ ๋ ๊ณ ์ํ ๊ฒ ๊ฐ์๋ฐ...
๋ง์ง๋ง ๊ตฌ๊ฐ์ ๊ฑฐ๋ฆฌ๋ฅผ ์ ์ ์๋ ๊ฐ์ ๋ฃ์ด์ค์ผํด์ InDistance๋ฅผ ๋ฃ๋ ๊ฒ ๊ฐ๊ธดํ๋ฐ
InDistance๊ฐ ์์ด์ง๋ ๋ฐ์์ ์(Count)๋ก ๋ค์ด๊ฐ๊ฒ ๋ ์๋ ์์ง ์๋์...?