QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#303028 | #2733. Rainfall Capture | Camillus | Compile Error | / | / | C++20 | 1.5kb | 2024-01-11 16:59:40 | 2024-01-11 16:59:41 |
Judging History
answer
#include "bits/stdc++.h"
using ll = long long;
using namespace std;
random_device rd;
mt19937_64 rnd(rd());
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
auto cost = [&]() -> int {
vector<int> left(n, -1);
vector<int> right(n, -1);
vector<int> Q;
for (int i = 0; i < n; i++) {
while (!Q.empty() && a[Q.back()] <= a[i]) {
Q.pop_back();
}
if (!Q.empty()) {
left[i] = Q.back();
}
Q.push_back(i);
}
Q.clear();
for (int i = n - 1; i >= 0; i--) {
while (!Q.empty() && a[Q.back()] < a[i]) {
Q.pop_back();
}
if (!Q.empty()) {
right[i] = Q.back();
}
Q.push_back(i);
}
int sum = 0;
for (int i = 0; i < n; i++) {
if (left[i] != -1 && right[i] != -1 && a[right[i]] != a[i]) {
sum += (right[i] - left[i] - 1) * (min(a[right[i]], a[left[i]]) - a[i]);
}
}
return sum;
};
set<int> Q;
sort(a.begin(), a.end());
while (1.l * clock() / CLOCKS_PER_SEC < 0.9l) {
shuffle(a.begin(), a.end(), rand());
Q.insert(cost());
}
for (int x : Q) {
cout << x << " ";
}
cout << "\n";
return 0;
}
详细
In file included from /usr/include/c++/11/string:52, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/bits/stl_algo.h: In instantiation of ‘void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _UGenerator = int]’: answer.code:69:16: required from here /usr/include/c++/11/bits/stl_algo.h:3750:9: error: ‘std::remove_reference<int>::type’ {aka ‘int’} is not a class, struct, or union type 3750 | __uc_type; | ^~~~~~~~~ /usr/include/c++/11/bits/stl_algo.h:3778:44: error: ‘std::remove_reference<int>::type’ {aka ‘int’} is not a class, struct, or union type 3778 | const pair<__uc_type, __uc_type> __pospos = | ^~~~~~~~ /usr/include/c++/11/bits/stl_algo.h:3778:44: error: ‘std::remove_reference<int>::type’ {aka ‘int’} is not a class, struct, or union type