QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#184817 | #6433. Klee in Solitary Confinement | KAZE_mae# | WA | 0ms | 3648kb | C++17 | 3.0kb | 2023-09-21 13:02:27 | 2023-09-21 13:02:28 |
Judging History
answer
/**
* @Author KAZE_mae
* @Website https://cloudfall.top/
* @Url
* @DateTime
*/
// #include <bits/stdc++.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using Ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using PII = pair<int, int>;
using PLI = pair<ll, int>;
using PLL = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
return (ull)rng() % B;
}
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define abs(a) ((a) >= 0 ? (a) : -(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lowbit(x) ((x) & (-x))
const int N = 1000005; // 1e6 + 5
const int INF = 0x3f3f3f3f;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-7;
const double PI = acos(-1.0);
const int MOD = 998244353;
// #define int long long
long long qmi(long long m, long long k, long long p = 2e18) {
int res = 1 % p, t = m;
while (k) {
if (k&1) res = res * t % p;
t = t * t % p, k >>= 1;
}
return res;
}
inline long long gcd(long long a, long long b) {
return b ? gcd(b, a % b) : a;
}
long long exgcd(long long a, long long b, long long &x, long long &y) {
if (!b) { x = 1; y = 0; return a; }
int d = exgcd(b, a % b, y, x);
y -= (a/b) * x;
return d;
}
void solve() {
int n, k, mx = 0;;
cin>> n >> k;
vector<int> a(n);
set<int> s;
map<int, vector<int> > mp;
map<int, int> sum;
int cnt = 1;
for(int i = 0; i < n; ++ i) {
cin>> a[i];
s.insert(a[i]);
sum[a[i]] ++;
if(i != 0) if(a[i] == a[i - 1]) ++ cnt;
else {
mp[a[i - 1]].push_back(cnt);
cnt = 1;
}
}
mp[a[n - 1]].push_back(cnt);
for(auto i : mp) {
for(auto j : i.second)
mx = max(j + sum[i.first + k], mx);
mx = max(sum[i.first], mx);
}
cout<< mx <<endl;
}
signed main() {
std::ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
// int _ = 1; cin>> _; while(_ --)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
5 2 2 2 4 4 4
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
7 1 3 2 3 2 2 2 3
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
7 1 2 3 2 3 2 3 3
output:
5
result:
ok 1 number(s): "5"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
9 -100 -1 -2 1 2 -1 -2 1 -2 1
output:
3
result:
ok 1 number(s): "3"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3596kb
input:
200 121649 0 527189 -1000000 -306471 -998939 527189 -1000000 -1000000 0 527189 0 527189 0 527189 -306471 -998939 -306471 -306471 -306471 0 0 527189 527189 1000000 527189 -1000000 1000000 648838 -1000000 -998939 -998939 -998939 0 1000000 -1000000 -998939 527189 1000000 648838 -1000000 1000000 648838 ...
output:
32
result:
wrong answer 1st numbers differ - expected: '37', found: '32'