๋ฌธ์
์ฝ๋
#include <iostream>
using namespace std;
int N, checkMilk,cnt;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N;
while (1) {
cin >> checkMilk;
if (checkMilk == 0) break;
else N--;
}
cnt++;
for (int i = 0; i < N; i++) {
int milk; cin >> milk;
if (checkMilk == 0 && milk == 1) {
cnt++;
checkMilk = milk;
}
else if (checkMilk == 1 && milk == 2) {
cnt++;
checkMilk = milk;
}
else if (checkMilk == 2 && milk == 0) {
cnt++;
checkMilk = milk;
}
}
cout << cnt;
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 14889๋ฒ - ์คํํธ์ ๋งํฌ (0) | 2021.11.14 |
---|---|
[๋ฐฑ์ค,c++] 1476๋ฒ - ๋ ์ง ๊ณ์ฐ (0) | 2021.11.14 |
[๋ฐฑ์ค,c++] 14724๋ฒ - ๊ด๋ฆฌ์๋ ๋๊ตฌ? (0) | 2021.11.11 |
[๋ฐฑ์ค,c++] 14716๋ฒ - ํ์๋ง (0) | 2021.11.11 |
[๋ฐฑ์ค,c++] 14698๋ฒ - ์ ์ํ๋๋ ์ฌ๋ผ์ ์ฐ๊ตฌ์์๋ ๊ฑด์ ๋ํ์ฌ(Hard) (0) | 2021.11.11 |
[๋ฐฑ์ค,c++] 14681๋ฒ - ์ฌ๋ถ๋ฉด ๊ณ ๋ฅด๊ธฐ (0) | 2021.11.11 |
๋๊ธ