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

[정렬] 3월 7일 #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion 03월_04일-정렬/12840.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ void query(int T, int c, int &total)
{
total = total + c;
if ( total >= 86400) { //하루가 넘어감
total -= 86400;
total = total % 86400;
}
}
else if (T == 2)
{
total = total - c;
if ( total < 0){ //전날로 넘어감
total = total % 86400;
total = 86400 + total;
}
}
Expand Down
9 changes: 7 additions & 2 deletions 03월_04일-정렬/1758.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

using namespace std;

int maxTip(int n, vector<int> &tip)
// N <= 100,000 (자연수)
// tip <= 100,000 (자연수)

//최댓값을 가정해보면 약 150억이 나온다. (맞나요..?)
//int형은 signed int형일 경우 20억(unsigned int는 40억)까지밖에 표현을 못하기 때문에 long long 타입을 사용해야 한다.
Comment on lines +10 to +11
Copy link

Choose a reason for hiding this comment

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

맞아요~~!! 정확히는 최댓값을 가정해보면 1 ~ 100000 를 모두 더한 값으로 약 50억이 나와요!! 😉
11번째 줄에 써주신 주석은 정확히 맞습니다~! 아주 좋아요 😎

앞으로 항상 문제 풀어주실 때, 맞게 푼 거 같은데 안 풀린다면 자료형의 범위를 넘어가진 않는지 확인해주는 게 좋습니다!

long long maxTip(int n, vector<int> &tip)
{
int t;
int max = 0;
long long max = 0;
for (int i = 0; i < n; i++)
{
t = tip[i] - i;
Expand Down