답안 #833261

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
833261 2023-08-22T03:48:28 Z vjudge1 Exam (eJOI20_exam) C++17
12 / 100
30 ms 5716 KB
#include<bits/stdc++.h>
using namespace std;

#define For(i, n) for (int i = 0; i < n; i++)
#define Each(x, v) for (auto x : v)
#define pb push_back

const int MAXN = 1e5;
int N, H[MAXN + 5], T[MAXN + 5];

bool ceksubsoal2() {
	int pivot = T[0];
	for (int i = 1; i < N; i++) {
		if (T[i] != T[0]) {
			return false;
		}
	}
	return true;
}

void subsoal2() {
	int target = T[0];
	vector <int> pos;
	set <int> ans;
	for (int i = 0; i < N; i++) {
		if (H[i] == target) {
			pos.pb(i);
			ans.insert(i);
		}
	}
	Each (x, pos) {
		for (int i = x - 1; i >= 0; i--) {
			if (H[i] < H[x]) ans.insert(i);
			else break;
		}
		for (int i = x + 1; i < N; i++) {
			if (H[i] < H[x]) ans.insert(i);
			else break;
		}
	}
	cout << (int) ans.size() << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N;
	For (i, N) cin >> H[i];
	For (i, N) cin >> T[i];
	if (ceksubsoal2()) subsoal2();
}

Compilation message

exam.cpp: In function 'bool ceksubsoal2()':
exam.cpp:12:6: warning: unused variable 'pivot' [-Wunused-variable]
   12 |  int pivot = T[0];
      |      ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 7 ms 1328 KB Output is correct
3 Correct 20 ms 3100 KB Output is correct
4 Correct 29 ms 5688 KB Output is correct
5 Correct 30 ms 5716 KB Output is correct
6 Correct 12 ms 2900 KB Output is correct
7 Correct 25 ms 5696 KB Output is correct
8 Correct 15 ms 1020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -