250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 원서
- PyQt
- 알고리즘 문제
- 쉬운 알고리즘 문제
- 백준
- nightroutine
- 코테 대비
- BFS
- sw expert
- STUDYENGLISH
- 삼성
- 알고리즘
- sw expert academy
- englishbook
- 직무면접
- 코딩테스트
- swexpertacademy
- the midnight library
- dfs
- English
- SQL
- 완전탐색
- 프로그래머스
- 코테
- D4
- 원서읽기
- 원서읽자
- 코테 준비
- MySQL
- readingbook
Archives
- Today
- Total
시나브로
[코딩테스트 연습 _ 스택/큐] 다리를 지나는 트럭 본문
728x90
#include <string>
#include <vector>
#include<iostream>
using namespace std;
int solution(int bridge_length, int weight, vector<int> truck_weights) {
int answer = 0;
int time=0;
int pass_point=0;
int in_point=0;
int box=truck_weights.size();
vector<int>list;
int rest_time=weight;
while(1){
if(truck_weights.size()<=pass_point)
break;
time++;
if(list[pass_point]+bridge_length<=time&&list.size()!=0){
rest_time+=truck_weights[pass_point++];
}
if(rest_time>=truck_weights[in_point]&&in_point<truck_weights.size()){
list.push_back(time);
rest_time-=truck_weights[in_point++];
}
}
answer=time;
return answer;
}
https://programmers.co.kr/learn/courses/30/lessons/42583
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
728x90
'알고리즘 > 프로그래머스' 카테고리의 다른 글
[ 프로그래머스 ] 124 나라의 숫자 (0) | 2020.04.04 |
---|---|
[코딩테스트 연습 _ 스택/큐] 기능 개발 (0) | 2020.03.13 |
[코딩테스트 연습 _ 스택/큐] 탑 (0) | 2020.03.13 |
[SQL 최고점 Kit _ JOIN] 보호소에서 중성화한 동물 (0) | 2020.01.07 |
[SQL 최고점 Kit _JOIN] 오랜 기간 보호한 동물 1 (0) | 2020.01.07 |
Comments