Skip to content

Commit

Permalink
Update 190401-container.md
Browse files Browse the repository at this point in the history
  • Loading branch information
super-fishz authored Apr 1, 2019
1 parent 820308a commit a759f04
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions PS/190401-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,52 @@ fun main() {
} else {
var min = 0

// while (boxes.size > 0) {
for (i in 0 until boxes.size) {
boxes.removeAt(i)
// crane 마다 포인터 두고 거기부터 desending 해가면 될 것 같은디...
while (boxes.size > 0) {
for (crane in cranes) {
val tmp_idx = boxes.indexOfFirst{ it <= crane }

if (tmp_idx > 0) {
boxes.removeAt(tmp_idx)
}
}
min++
}

println(min)
}
}
```
푸는중...
kotlin 메모리 초과. 그럴 수 있지.
array가 immutable 이라... kotlin으로 풀긴 구리다! 라고 결론짓고... js로 선회

```javascript
var input = require('fs').readFileSync('/dev/stdin').toString().split('\n');

var craneCount = parseInt(input[0]);
var cranes = input[1].split(" ").map(function(v){return parseInt(v)});
cranes.reverse();

var boxCount = parseInt(input[2]);
var boxes = input[3].split(" ").map(function(v){return parseInt(v)});
boxes.reverse();

var min = -1;

if (boxes[0] <= cranes[0]) {
min = 0;
while (boxes.length > 0) {
for (var i in cranes) {
var crane = cranes[i];
var tmp_idx = boxes.findIndex(function(it){return it <= crane});

if (tmp_idx > -1) {
boxes.splice(tmp_idx, 1);
}
}
min++;
}
}

console.log(min);
```
는 틀린답... 왜때문에...

0 comments on commit a759f04

Please sign in to comment.