From fa6535f894c53ce660bab64b8c40254a0a07b36b Mon Sep 17 00:00:00 2001 From: changicho Date: Tue, 27 Oct 2020 23:28:30 +0900 Subject: [PATCH] =?UTF-8?q?=ED=92=80=EC=9D=B4:=20=EB=B0=B1=EC=A4=80.1034.?= =?UTF-8?q?=EB=9E=A8=ED=94=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ?: 램프를 toggle하는 규칙을 이용해 풀이 --- problems/baekjoon/1034/changi.cpp | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 problems/baekjoon/1034/changi.cpp diff --git a/problems/baekjoon/1034/changi.cpp b/problems/baekjoon/1034/changi.cpp new file mode 100644 index 0000000..965648f --- /dev/null +++ b/problems/baekjoon/1034/changi.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +#include + +using namespace std; + +void solution() { + vector lamps; + int answer = 0; + int N, M, K; + + cin >> N >> M; + + lamps.resize(N); + for (int i = 0; i < N; i++) { + cin >> lamps[i]; + } + + cin >> K; + + for (int y = 0; y < N; y++) { + int zeroCount = 0; + + for (char c : lamps[y]) { + if (c == '0') zeroCount++; + } + + int sum = 0; + + if (zeroCount <= K && zeroCount % 2 == K % 2) { + for (int temp_y = 0; temp_y < N; temp_y++) { + if (lamps[y] == lamps[temp_y]) { + sum++; + } + } + } + + answer = max(sum, answer); + } + + cout << answer << "\n"; +} + +int main() { + ios_base ::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + solution(); + + return 0; +} \ No newline at end of file