-
Notifications
You must be signed in to change notification settings - Fork 0
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
[ 우선순위 큐 ] 9월 19일 #5
Open
sari-harin
wants to merge
7
commits into
main
Choose a base branch
from
04_우선순위_큐
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "04_\uC6B0\uC120\uC21C\uC704_\uD050"
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
652101c
[ 정수론 ]
sari-harin e376f98
[ 정수론 ] 9월 7일
sari-harin daf1213
[ 브루트포스 ] 9월 13일
sari-harin 56b3220
[ 우선순위 큐 ] 9월 19일
sari-harin 80d27a9
[ 우선순위 큐 ] 9월 21일
af505ba
Delete 04_브루트포스 directory
sari-harin 7997aca
Delete 03_정수론 directory
sari-harin 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,33 @@ | ||
#include <iostream> | ||
#include <queue> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n, a, gift; | ||
priority_queue<int> pq; | ||
|
||
cin >> n; | ||
|
||
while(n--){ | ||
cin >> a; | ||
if(a==0){ | ||
if(pq.empty()){ | ||
cout << -1 << '\n'; | ||
} | ||
else{ | ||
cout << pq.top() << '\n'; | ||
pq.pop(); | ||
} | ||
} | ||
else{ | ||
while(a--){ | ||
cin >> gift; | ||
pq.push(gift); | ||
} | ||
} | ||
} | ||
|
||
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,29 @@ | ||
#include <iostream> | ||
#include <queue> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
|
||
ios_base::sync_with_stdio(false); | ||
cin.tie(NULL); | ||
cout.tie(NULL); | ||
|
||
int n, num; | ||
priority_queue<int, vector<int>, greater<int>> pq; | ||
|
||
cin >> n; | ||
|
||
for(int i=0;i<n*n;i++){ | ||
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. 연산 부분을 잘 구현해주셨네요~! |
||
cin >> num; | ||
pq.push(num); | ||
if(pq.size() > n){ | ||
pq.pop(); | ||
} | ||
} | ||
|
||
cout << pq.top(); | ||
|
||
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 <iostream> | ||
#include <vector> | ||
|
||
using namespace std; | ||
|
||
const int NUM_CHARS = 26; //상수 선언 | ||
|
||
void countFreq(string word, vector<int> &freq) { //각 알파벡의 개수를 센다 | ||
for (int i = 0; i < word.length(); i++) { //받은 단어의 알파벳을 모두 돌며 | ||
freq[word[i] - 'A']++; //받은 벡터에 각 알파벳의 개수를 센다 | ||
} | ||
} | ||
|
||
int countDiff(string word, vector<int> original_freq) { //차이를 센다 | ||
vector<int> freq(NUM_CHARS, 0); //빈도(개수)를 세는 벡터 | ||
int diff = 0; //원본 단어와의 차이를 저장할 변수 | ||
|
||
countFreq(word, freq); // 각 알파벳의 개수 세기 | ||
|
||
for (int i = 0; i < NUM_CHARS; i++) { //알파벳 개수동안 | ||
diff += abs(original_freq[i] - freq[i]); //원본 단어와 다른 알파벳의 개수를 변수에 넣기 | ||
} | ||
return diff; //diff를 반환 | ||
} | ||
|
||
int main() { //메인 | ||
int N, ans=0; //입력받을 변수와 결과를 담을 변수 | ||
string original; //원본 문자열 | ||
|
||
cin >> N; //입력 받기 | ||
cin >> original; //원본 문자열 입력 받기 | ||
vector<int> original_freq(NUM_CHARS, 0); //기존 문자열에서 알파벳의 개수를 저장할 벡터 | ||
|
||
countFreq(original, original_freq); //기존 문자열의 알파벳의 개수 계산 | ||
|
||
for (int i = 1; i < N; i++) { //입력받은 n만큼 반복 | ||
string word; //비교할 문자열 | ||
cin >> word; //비교할 문자열 입력받기 | ||
|
||
int diff = countDiff(word, original_freq); //기존 문자열과의 차이 저장 | ||
|
||
if (diff == 0 || diff == 1 || diff == 2 && original.length() == word.length()) { //조건에 맞는 비슷한 단어라면 | ||
ans++; //개수 세기 | ||
} | ||
} | ||
|
||
cout << ans; //결과 출력 | ||
return 0; //종료 | ||
} |
Submodule Altu-Bitu-HarinLee
added at
f130cd
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.
cout << "-1\n";
이렇게 한번에 작성해도 돼요!