본문 바로가기

코딩테스트 준비

백준 12845_모두의마블

계산식을 세우는게 이정도로 중요하다를 깨닫게해준. .
어려운길 돌아가지 말구 걍 생각쩜 더 하면서 풀면 되는
이래서 수학 잘하는 넘들이 코딩도 잘하는군 ;;
#include<iostream>
//#include<math.h>
using namespace std;


// 계산식을 생각해고 풀면 좋은 문제인듯
// 이딴걸로 고민한게 좆같음 ..

int main(){

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    int max_num =0;
    int sum =0;
            int num;

    

    cin >>n;

    for(int i=0; i<n; i++){
        cin >>num;
        sum+=num;
        max_num = max(num, max_num);
        
    }

    cout << sum + max_num*(n-2);
}

'코딩테스트 준비' 카테고리의 다른 글

Summer/Winter Coding(~2018)소수 만들기_c++  (0) 2021.05.06
1026_보물 백준 c++  (0) 2021.04.16
2217_로프 백준 Greedy  (0) 2021.01.08
2217_로프 백준 Greedy  (0) 2021.01.07
백준 11047 동전 0 Greedy Algorithm  (0) 2021.01.07