Compile Error
foo.cc: In function 'int main()': foo.cc:26:7: error: 'sort' was not declared in this scope; did you mean 'short'? 26 | sort(a.rbegin(), a.rend()); | ^~~~ | short
Code
#include <iostream>
#include<vector>
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:26
- Judged At
- 2025-06-14 07:01:26
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes