QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#250605 | #6433. Klee in Solitary Confinement | hhoppitree# | Compile Error | / | / | C++14 | 1.9kb | 2023-11-13 13:59:15 | 2023-11-13 13:59:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int D = 1e6 + 2;
vector<int> M[(D << 1) + 6];
vector< pair<int, int> > id;
signed main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1, x; i <= n; ++i) {
scanf("%d", &x);
M[x + D].push_back(i);
}
int res = 0;
for (int i = -D; i <= D; ++i) {
id.clear();
if (M[i + D].empty()) {
continue;
}
for (auto x : M[i + D]) {
id.push_back(make_pair(x, -1));
}
if (i - m >= -D && i - m <= D) {
for (auto x : M[i - m + D]) {
id.push_back(make_pair(x, 1));
}
}
sort(id.begin(), id.end());
int s = 0, mx = 0;
for (auto [x, y] : id) {
s += y;
if (s < 0) {
s = 0;
}
mx = max(mx, s);
}
res = max(res, mx + (int)M[i + D].size());
}
printf("%d\n", res);
return 0;
}#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, D = 1e6;
vector<int> M[D << 1];
vector< pair<int, int> > id;
signed main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1, x; i <= n; ++i) {
scanf("%d", &x);
M[x + D].push_back(i);
}
int res = 0;
for (int i = -D; i <= D; ++i) {
id.clear();
for (auto x : M[i + D]) {
id.push_back(make_pair(x, -1));
}
if (i - m >= -D && i - m <= D) {
for (auto x : M[i - m + D]) {
id.push_back(make_pair(x, 1));
}
}
sort(id.begin(), id.end());
int s = 0, mx = 0;
for (auto [x, y] : id) {
s += y;
if (s < 0) {
s = 0;
}
mx = max(mx, s);
}
res = max(res, mx + (int)M[i + D].size());
}
printf("%d\n", res);
return 0;
}
Details
answer.code:45:2: error: stray ‘#’ in program 45 | }#include <bits/stdc++.h> | ^ answer.code: In function ‘int main()’: answer.code:34:19: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ 34 | for (auto [x, y] : id) { | ^ answer.code: At global scope: answer.code:45:3: error: ‘include’ does not name a type 45 | }#include <bits/stdc++.h> | ^~~~~~~ answer.code:49:24: error: redefinition of ‘const int D’ 49 | const int N = 1e6 + 5, D = 1e6; | ^ answer.code:5:11: note: ‘const int D’ previously defined here 5 | const int D = 1e6 + 2; | ^ answer.code:51:13: error: conflicting declaration ‘std::vector<int> M [2000004]’ 51 | vector<int> M[D << 1]; | ^ answer.code:7:13: note: previous declaration as ‘std::vector<int> M [2000010]’ 7 | vector<int> M[(D << 1) + 6]; | ^ answer.code:52:26: error: redefinition of ‘std::vector<std::pair<int, int> > id’ 52 | vector< pair<int, int> > id; | ^~ answer.code:8:26: note: ‘std::vector<std::pair<int, int> > id’ previously declared here 8 | vector< pair<int, int> > id; | ^~ answer.code:54:8: error: redefinition of ‘int main()’ 54 | signed main() | ^~~~ answer.code:10:8: note: ‘int main()’ previously defined here 10 | signed main() | ^~~~ answer.code: In function ‘int main()’: answer.code:75:19: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ 75 | for (auto [x, y] : id) { | ^ answer.code: In function ‘int main()’: answer.code:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d%d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~ answer.code:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d", &x); | ~~~~~^~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:57:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 57 | scanf("%d%d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~ answer.code:59:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 59 | scanf("%d", &x); | ~~~~~^~~~~~~~~~