-
Notifications
You must be signed in to change notification settings - Fork 9
두 스티커 / 실버 3 / 30분 / O #341
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
Open
10o0o
wants to merge
1
commit into
main
Choose a base branch
from
BOJ_16937_최재선
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: "BOJ_16937_\uCD5C\uC7AC\uC120"
Open
Changes from all commits
Commits
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 hidden or 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,96 @@ | ||
| #include <iostream> | ||
| #include <vector> | ||
| #include <algorithm> | ||
|
|
||
| using namespace std; | ||
|
|
||
| int checkFlag(int inr, int inc, int outr, int outc, int maxLen, int minLen) { | ||
| int r1 = max(outr, inr); | ||
| int c1 = outc + inc; | ||
|
|
||
| int r2 = max(outr, inc); | ||
| int c2 = outc + inr; | ||
|
|
||
| int r3 = outr + inc; | ||
| int c3 = max(outc, inr); | ||
|
|
||
| int r4 = outr + inr; | ||
| int c4 = max(outc, inc); | ||
|
|
||
| int max1 = max(r1, c1); | ||
| int min1 = min(r1, c1); | ||
| int max2 = max(r2, c2); | ||
| int min2 = min(r2, c2); | ||
| int max3 = max(r3, c3); | ||
| int min3 = min(r3, c3); | ||
| int max4 = max(r4, c4); | ||
| int min4 = min(r4, c4); | ||
|
|
||
|
|
||
| if (max1 <= maxLen && min1 <= minLen) { | ||
| return 1; | ||
| } | ||
|
|
||
| if (max2 <= maxLen && min2 <= minLen) { | ||
| return 1; | ||
| } | ||
|
|
||
| if (max3 <= maxLen && min3 <= minLen) { | ||
| return 1; | ||
| } | ||
|
|
||
| if (max4 <= maxLen && min4 <= minLen) { | ||
| return 1; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| int main() { | ||
| ios_base::sync_with_stdio(false); | ||
| cin.tie(NULL); | ||
|
|
||
| int h, w, n; | ||
|
|
||
| cin >> h >> w; | ||
| cin >> n; | ||
|
|
||
| vector<vector<int>> board(h, vector<int>(w, 0)); | ||
| vector<vector<int>> stickers(n, vector<int>(2)); | ||
|
|
||
| for (int i = 0; i < n; i += 1) { | ||
| int r, c; | ||
| cin >> r >> c; | ||
|
|
||
| stickers[i] = {r, c}; | ||
| } | ||
|
|
||
| sort(stickers.begin(), stickers.end(), [](const vector<int>&a, const vector<int>&b) { | ||
| return a[0] * a[1] > b[0] * b[1]; | ||
| }); | ||
|
|
||
| int maxLen = max(h, w); | ||
| int minLen = min(h, w); | ||
| int sum = 0; | ||
| int count = 0; | ||
|
|
||
| for (int i = 0; i < n - 1; i += 1) { | ||
| const int outr = stickers[i][0]; | ||
| const int outc = stickers[i][1]; | ||
|
|
||
|
|
||
| for (int j = i + 1; j < n; j += 1) { | ||
| const int inr = stickers[j][0]; | ||
| const int inc = stickers[j][1]; | ||
|
|
||
| if (checkFlag(inr, inc, outr, outc, maxLen, minLen)) { | ||
| sum = max(sum, inr * inc + outr * outc); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| cout << sum; | ||
|
|
||
| return 0; | ||
| } | ||
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.
크게보면 4가지 경우만으로도 구해지는 거였군요..
이렇게 보니까 좀더 잘 이해가 되는 것 같습니다 :)