heyjinn.dev
헤이지니
heyjinn.dev
  • 분류 전체보기 (66)
    • 알고리즘 💻 (21)
      • BOJ (12)
      • 요약정리 (6)
      • 과제 (3)
    • BackEnd 🌱 (13)
      • spring (13)
    • 📚study✨ (12)
      • Docker & Kubernetes (8)
      • 기타 (4)
    • ComputerScience 🐥 (8)
      • 운영체제 (0)
      • 컴퓨터네트워크 (8)
      • 데이터베이스 (0)
    • 에러 해결 👍 (6)
    • 후기 🔥 (4)
      • 세미나 (2)
      • 인턴 (0)
      • 프로젝트 (0)
    • 기타 (0)
    • 일상 (1)

인기 글

태그

  • EC2
  • 순열
  • 자바
  • dfs
  • 조합
  • 두 원 사이의 정수 쌍
  • AWS
  • 백트래킹
  • Python
  • 프로그래머스

최근 글

07-15 00:01
전체 방문자
오늘
어제
hELLO · Designed By 정상우.
heyjinn.dev
공통과제 1번 <그릇>
알고리즘 💻/과제

공통과제 1번 <그릇>

2022. 2. 4. 17:09

 

//
//  Copyright (c) 2021 HyeJin Shin All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    freopen("dish.inp","r",stdin);
    freopen("dish.out","w",stdout);
    
    int T;
    int n;
    string s;
    cin>>T;
    while(T--){
        int cnt=10;
        cin >> n;
        cin>>s;
       
        for(int i=1;i<s.length();i++){
            if(s[i]=='('){
                if(s[i-1]=='('){cnt+=5;}
                else if(s[i-1]==')'){cnt+=10;}
            }
            else if(s[i]==')'){
                if(s[i-1]=='('){cnt+=10;}
                else if(s[i-1]==')'){cnt+=5;}
            }
        }
        cout<<cnt<<endl;
    }
}

https://github.com/toki0411/Algorithm/blob/main/dish.cpp

 

GitHub - toki0411/Algorithm

Contribute to toki0411/Algorithm development by creating an account on GitHub.

github.com

백준에도 있는 문제였기도 하고, DUCC 본선에서도 풀어본 적 있는 문제라 쉽게 풀 수 있었다. 

    '알고리즘 💻/과제' 카테고리의 다른 글
    • 공통과제 3번 <Good Matrix>
    • 공통과제 2번 <격자에서 걷기 1>
    heyjinn.dev
    heyjinn.dev
    안녕하세요 ~ https://github.com/toki0411 부족하지만 열심히 공부중입니다 :D

    티스토리툴바