Submission #1156235


Source Code Expand

/// a.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,C,k;
    fi>>n>>C>>k;
    static int s[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    sort(s + 1,s + 1 + n);
    int ans = 0;
    for (int i = 1;i <= n;)
    {
        int time = s[i] + k;
        int nxt = min(n,i + C - 1);
        while (i <= nxt && s[i] <= time)
            ++i;
        ++ans;
    }
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Submission Info

Submission Time
Task A - Airport Bus
User reality
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1663 Byte
Status AC
Exec Time 61 ms
Memory 764 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 9 ms 764 KB
in2.txt AC 61 ms 640 KB
in3.txt AC 60 ms 640 KB
in4.txt AC 59 ms 640 KB
in5.txt AC 2 ms 256 KB
in6.txt AC 60 ms 640 KB
in7.txt AC 52 ms 640 KB
in8.txt AC 60 ms 640 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB