Skip to content

Instantly share code, notes, and snippets.

@fpdjsns
Created January 5, 2019 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fpdjsns/0b45dd9a83490ad5a88de8be9dbed284 to your computer and use it in GitHub Desktop.
Save fpdjsns/0b45dd9a83490ad5a88de8be9dbed284 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
for (int c = 1; c <= 10; c++) {
int ans = 0;
int n;
cin >> n;
// 왼쪽 2개, 체크1개, 오른쪽 2개
vector<int> arr(5, 0);
for (int i = 0; i < n; i++) {
cin >> arr[i % 5];
// check 2번째 전
int checkInd = (i+ 3) % 5;
int maxNum = 0;
for (int j = 0; j < 5; j++) {
if (checkInd == j) continue;
maxNum = max(maxNum, arr[j]);
}
int diff = arr[checkInd] - maxNum;
ans += diff < 0 ? 0 : diff;
}
printf("#%d %d\n", c, ans);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment