Skip to content

Commit

Permalink
unsolve/#173: 프로그래머스 파괴되지 않은 건물 - 효율성 테스트 시간 초과
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-muuu committed Oct 24, 2023
1 parent 0dc8ed3 commit e916dd6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions AlgorithmReview.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
EED6FC712A020BE5006F6D72 /* 2493.swift in Sources */ = {isa = PBXBuildFile; fileRef = EED6FC702A020BE5006F6D72 /* 2493.swift */; };
EED6FC772A036698006F6D72 /* 2800.swift in Sources */ = {isa = PBXBuildFile; fileRef = EED6FC762A036698006F6D72 /* 2800.swift */; };
EEE527322AE624B5000A3505 /* 부대 복귀.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEE527312AE624B5000A3505 /* 부대 복귀.swift */; };
EEE527382AE782FB000A3505 /* 파괴되지 않은 건물.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEE527372AE782FB000A3505 /* 파괴되지 않은 건물.swift */; };
EEEA901A2A89DC6F00EBE008 /* 수식 최대화.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEEA90192A89DC6F00EBE008 /* 수식 최대화.swift */; };
EEEA901E2A8B24A800EBE008 /* 행렬 테두리 회전하기.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEEA901D2A8B24A800EBE008 /* 행렬 테두리 회전하기.swift */; };
EEEA90302A8F2A5C00EBE008 /* 이모티콘 할인행사.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEEA902F2A8F2A5C00EBE008 /* 이모티콘 할인행사.swift */; };
Expand Down Expand Up @@ -195,6 +196,7 @@
EEE1154C29A775C4003FD4E3 /* 모의고사.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "모의고사.swift"; sourceTree = "<group>"; };
EEE1155129A8427E003FD4E3 /* 소수 만들기.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "소수 만들기.swift"; sourceTree = "<group>"; };
EEE527312AE624B5000A3505 /* 부대 복귀.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "부대 복귀.swift"; sourceTree = "<group>"; };
EEE527372AE782FB000A3505 /* 파괴되지 않은 건물.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "파괴되지 않은 건물.swift"; sourceTree = "<group>"; };
EEE5D6912A6670F90009DCB5 /* 마법의 엘리베이터.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "마법의 엘리베이터.swift"; sourceTree = "<group>"; };
EEEA8FF92A84A7CA00EBE008 /* 혼자서 하는 틱택토.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "혼자서 하는 틱택토.swift"; sourceTree = "<group>"; };
EEEA90032A85D0FD00EBE008 /* 요격 시스템.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "요격 시스템.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -464,6 +466,7 @@
EE123C1C2ADFAAFB00832264 /* 다단계 칫솔 판매.swift */,
EEA92DFF2AE0EE9500C63ED6 /* 순위.swift */,
EEE527312AE624B5000A3505 /* 부대 복귀.swift */,
EEE527372AE782FB000A3505 /* 파괴되지 않은 건물.swift */,
);
path = Lv3;
sourceTree = "<group>";
Expand Down Expand Up @@ -566,6 +569,7 @@
EEAEC89F298CACDD001B1D62 /* main.swift in Sources */,
EE5CEEC62A39A6BB00E1907E /* 가장 큰 정사각형 찾기.swift in Sources */,
EE2738C429C193A3006077A3 /* 대충 만든 자판.swift in Sources */,
EEE527382AE782FB000A3505 /* 파괴되지 않은 건물.swift in Sources */,
EECBCFEE2ADCFEB90056BC96 /* 연속 펄스 부분 수열의 합.swift in Sources */,
EE2E5E6C29B5884D00545253 /* 체육복.swift in Sources */,
EECBCFF02ADE55970056BC96 /* 풍선 터뜨리기.swift in Sources */,
Expand Down
33 changes: 33 additions & 0 deletions AlgorithmReview/Programmers/Lv3/파괴되지 않은 건물.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// 파괴되지 않은 건물.swift
// AlgorithmReview
//
// Created by 박소윤 on 2023/10/24.
//

import Foundation

func solution(_ board:[[Int]], _ skill:[[Int]]) -> Int {

let (row, col) = (board.count, board[0].count)

var board = board
for s in skill {
let degree = s[0] == 1 ? -s[5] : s[5]
for i in s[1]...s[3]{
for j in s[2]...s[4]{
board[i][j] += degree
}
}
}

var ans = 0
for i in 0..<row {
for j in 0..<col {
if board[i][j] > 0 {
ans += 1
}
}
}
return ans
}

0 comments on commit e916dd6

Please sign in to comment.