"Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword in the darkness. I am the watcher on the walls. I am the shield that guards the realms of men. I pledge my life and honor to the Night's Watch, for this night and all the nights to come." — The Night's Watch oath.
With that begins the watch of Jon Snow. He is assigned the task to support the stewards.
This time he has n stewards with him whom he has to provide support. Each steward has his own strength. Jon Snow likes to support a steward only if there exists at least one steward who has strength strictly less than him and at least one steward who has strength strictly greater than him.
Can you find how many stewards will Jon support?
Input
First line consists of a single integer n (1 ≤ n ≤ 105) — the number of stewards with Jon Snow.
Second line consists of n space separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) representing the values assigned to the stewards.
Output
Output a single integer representing the number of stewards which Jon will feed.
코포 좀 했다고 생긴 짬 : 앞에 주저리 거리는 건 문제랑 관련 없다
그래서 맨 처음에 있는 글은 그냥 건너뛰었다. 영어 쓰는 사람들은 ㄷㄱㄷㄱ 스토리 있는 문제네! 하겠지만 난 독해의 연장선일 뿐이다.. 패스!
이 문제도 해석이 안 돼서 또 막혔음ㅋㅋㅋㅋㅜㅜ
이 문장!
Jon Snow likes to support a steward only if there exists at least one steward who has strength strictly less than him and at least one steward who has strength strictly greater than him.
밥을 준대! (이해했음) 기준이 있는데 이 기준보다 작거나 큰 애한테 밥을 준대! (이해했음) 그런데 아무리 봐도 기준을 모르겠다. 기준이 주어진 것도 없고 뭐지 싶었다. 결국 Note 보고 적당히 알아들었다.
1 2 5는 2가 1보다 크고 5보다 작으므로 밥을 먹는다. 그래서 최댓값과 최솟값 사이 수의 개수를 구하면 되겠다 싶었음.
int main() {
int n;
scanf("%d", &n);
// vector<int> v(n);
// for(int i = 0; i < n; i++){
// scanf("%d", &v[i]);
// }
// for(int i = 0; i < n; i++){
// printf("%d ", v[i]);
// }
// int max = *max_element(v.begin(), v.end());
// int min = *min_element(v.begin(), v.end());
// int count = 0;
// for(int i = 0; i < n; i++){
// }
printf("%d", max(0, n-2));
return 0;
}
열심히 짜다가 어? 최소 최대 빼고 개수를 구하면 되니깐 2를 빼는게 답 아닐까? 해서 냈다. 물론 틀렸음 111555 이런 수면 어떡할꺼야
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
using namespace std;
using i64 = long long;
//printf("%d", );
//scanf("%d", &);
//printf("\n");
int main() {
int n;
scanf("%d", &n);
vector<int> v(n);
for(int i = 0; i < n; i++){
scanf("%d", &v[i]);
}
sort(v.begin(), v.end());
// for(int i = 0; i < n; i++){
// printf("%d ", v[i]);
// }
int count = 0;
for(int i = 1; i < n-1; i++){
if(v[0] < v[i] && v[i] < v[n-1])
count++;
}
printf("%d", count);
return 0;
}
그래서 sorting 한 다음에 그냥 개수 셌다.
'코드포스' 카테고리의 다른 글
[코드포스 Practice5] D. K-Dominant Character (0) | 2019.11.27 |
---|---|
[코드포스 Practice5] C. Mind the Gap (0) | 2019.11.27 |
[코드포스 Practice5] A. Splitting into digits (0) | 2019.11.27 |
[코드포스 Practice5] 후기 (0) | 2019.11.27 |
[코드포스 Practice4] E. Modular Equations (0) | 2019.11.20 |