티스토리 뷰

알고리즘/SWEA

[SWEA 1206] View

히더 2018. 8. 5. 15:18

출처 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV134DPqAA8CFAYh#none


#include <iostream>

#include <algorithm>

#include <memory.h>

using namespace std;


int N, arr[1000], result;


int main()

{

int t = 1, T = 10;

while (T--)

{

result = 0; memset(arr, 0, sizeof(arr));

cin >> N;

for (int i = 0; i < N; i++)cin >> arr[i];

for (int i = 2; i < N - 2; i++)

{

int tmp = arr[i] - max(max(arr[i - 2], arr[i - 1]), max(arr[i + 1], arr[i + 2]));

if (tmp > 0) result += tmp;

}


cout << "#" << t++ << " " << result << endl;

}


return 0;

}


'알고리즘 > SWEA' 카테고리의 다른 글

[SWEA 1204] 최빈수 구하기  (0) 2018.08.06
[SWEA 1208] Flatten  (0) 2018.08.06
[SWEA 4672] 수진이의 팰린드롬  (0) 2018.07.29
[SWEA 4796] 의석이의 우뚝 선 산  (0) 2018.07.26
[SWEA 4789] 성공적인 공연 기획  (0) 2018.07.26
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
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 31
글 보관함