Submission #1477645


Source Code Expand

#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,c,k; cin>>n>>c>>k;
    vector<int>v(n); rep(i,n)cin>>v[i];
    sort(all(v));
    auto itr=v.begin();
    auto iend=v.begin()+c;
    int ans=0;
    int key=v[0];
    while(true){
        ans++;
        auto next=upper_bound(itr,iend,key+k);
        if(next!=iend){
            key=*(next);
            itr=next;
        }else if(next==iend){
            if(iend==v.end())break;
            key=*(iend);
            itr=iend;
        }
        if(itr+c>v.end())iend=v.end();
        else iend=itr+c;
    }
    cout<<ans<<endl;
}

Submission Info

Submission Time
Task A - Airport Bus
User yebityon
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1691 Byte
Status AC
Exec Time 47 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 12
Set Name Test Cases
Sample sample1.txt, sample2.txt
All sample1.txt, sample2.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt
Case Name Status Exec Time Memory
in1.txt AC 1 ms 256 KB
in2.txt AC 46 ms 640 KB
in3.txt AC 47 ms 640 KB
in4.txt AC 47 ms 640 KB
in5.txt AC 2 ms 256 KB
in6.txt AC 47 ms 640 KB
in7.txt AC 41 ms 640 KB
in8.txt AC 46 ms 640 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB