Compile Error
foo.cc: In function 'int main()': foo.cc:12:5: error: 'vector' was not declared in this scope 12 | vector<int> a(n); | ^~~~~~ foo.cc:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'? 1 | #include <iostream> +++ |+#include <vector> 2 | foo.cc:12:12: error: expected primary-expression before 'int' 12 | vector<int> a(n); | ^~~ foo.cc:13:12: error: expected primary-expression before 'int' 13 | vector<int> b(n); | ^~~ foo.cc:17:14: error: 'a' was not declared in this scope 17 | cin >> a[i]; | ^ foo.cc:20:14: error: 'b' was not declared in this scope 20 | cin >> b[j]; | ^ foo.cc:25:12: error: 'a' was not declared in this scope 25 | sort(a.rbegin(), a.rend()); | ^ foo.cc:25:7: error: 'sort' was not declared in this scope; did you mean 'short'? 25 | sort(a.rbegin(), a.rend()); | ^~~~ | short foo.cc:26:12: error: 'b' was not declared in this scope 26 | sort(b.rbegin(), b.rend()); | ^
Code
#include <iostream>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n);
vector<int> b(n);
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
for (int j = 0; j < n; j++) {
cin >> b[j];
}
if (n == 1 || n == 2)
cout << "Yes" << endl;
else {
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
int flag = 0;
int count = 0;
for (int k = 0; k < n - 2; k++) {
if ((a[k] > b[k] && a[k] > b[k + 2]) ||
(b[k] > a[k] && b[k] > a[k + 2])) {
count++;
} else {
flag = 1;
break;
}
}
if (count == n - 2)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1193 C. Roy and Peak Array
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-06-14 07:01:15
- Judged At
- 2025-06-14 07:01:15
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes