Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
230099954 Practice:
1v7w
1041C - 18 C++17 (GCC 9-64) Wrong answer on test 9 93 ms 4912 KB 2023-10-28 05:39:30 2023-10-28 05:39:30
→ Source
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>

#define fi first
#define se second

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const double eps = 1e-4;
const int N = 2e5+10;
ll n, m, d;
int b[N];
vector<pair<ll, ll>> a;

void solve() {
    scanf("%lld%lld%lld", &n, &m, &d);
    for (int i=1; i<=n; i++) {
        ll x; scanf("%lld", &x);
        a.push_back({x, i});
    }
    sort(a.begin(), a.end());
    int res = 0;
    for (int i=0, j=0; i<(int)a.size(); i++) {
        while (j < (int)a.size() && a[j].fi < a[i].fi + d + 1) {
            b[a[j].se] = j - i + 1;
            j++;
        }
        res = max(res, j - i);
        i = j - 1;
    }
    printf("%d\n", res);
    for (int i=1; i<=n; i++) {
        printf("%d%c", b[i], " \n"[i==n]);
    }
}

int main() {
    // multiple case
    // int t; scanf("%d", &t);
    // while(t--) {
    //     solve();
    // }

    // single case
    solve();

    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details