Skip to content

Commit

Permalink
solve/#181: swift 풀이
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-muuu committed Feb 2, 2024
1 parent 2b15a74 commit 490f2dc
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions AlgorithmReview/softeer/GBC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// GBC.swift
// AlgorithmReview
//
// Created by 박소윤 on 2024/02/02.
//

import Foundation

let size = readLine()!.split(separator: " ").map{ Int($0)! }
let (n, m) = (size[0], size[1])

var limit = [Int](repeating: 0, count: 101)
var p = 1
for _ in 0..<n {
let data = readLine()!.split(separator: " ").map{ Int($0)! }
for j in p..<p+data[0] {
limit[j] = data[1]
}
p = p+data[0]
}

p = 1
var answer = 0
for _ in 0..<m {
let data = readLine()!.split(separator: " ").map{ Int($0)! }
for j in p..<p+data[0]{
if limit[j] < data[1] {
answer = max(answer, data[1]-limit[j])
}
}
p = p+data[0]
}

print(answer)

/*
Test 1
3 3
50 50
40 40
10 30
60 76
18 28
22 50
*/

/*
Test 2
3 3
50 90
10 90
40 50
50 40
10 100
40 40
*/

0 comments on commit 490f2dc

Please sign in to comment.