# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
833251 |
2023-08-22T03:44:06 Z |
vjudge1 |
Exam (eJOI20_exam) |
C++17 |
|
0 ms |
0 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], ans = 0;
vector <int> pos;
for (int i = 0; i < N; i++) {
if (H[i] == target) {
pos.pb(i);
ans++;
}
}
Each (x, pos) {
for (int i = x - 1; i >= 0; i--) {
if (H[i] < H[x]) {
ans++;
}
else break;
}
for (int i = x + 1; i < N; i++) {
if (H[i] < H[x]) {
ans++;
}
else break;
}
}
cout << ans << 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();
else cout << f(0, N - 1) << endl;
}
Compilation message
exam.cpp: In function 'bool ceksubsoal2()':
exam.cpp:12:6: warning: unused variable 'pivot' [-Wunused-variable]
12 | int pivot = T[0];
| ^~~~~
exam.cpp: In function 'int main()':
exam.cpp:54:15: error: 'f' was not declared in this scope
54 | else cout << f(0, N - 1) << endl;
| ^