Submission #1164131


Source Code Expand

Copy
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;

ll N, C, K, temp, ans = 0;
vector<ll> T;
bool fir = true, go = false;

int main() {
	scanf("%lld%lld%lld", &N, &C, &K);
	REP(i, N) {
		scanf("%lld", &temp);
		T.push_back(temp + K);
	}
	sort(T.begin(), T.end());
	ll count = 0;
	REP(i, N) {
		//count++;
		if (i==N-1||(T[i + 1] - K)>temp)go = true;
		if (fir) {
			temp = T[i];
			//count++;
			fir = false;

		}
		if (!fir) {
			if (temp >= T[i] - K) {
				if (C>count)count++;

			}
			else {
				go = true;
			}

		}
		//    cout<<temp<<":"<<count<<":"<<T[i]<<endl;
		if (count != 0 && i + 1 == N) { go = true; }
		if (C <= count || go) {
			count = 0;
			fir = true;
			go = false;
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Submission Info

Submission Time
Task A - Airport Bus
User eiya
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1080 Byte
Status
Exec Time 20 ms
Memory 1400 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld", &N, &C, &K);
                                   ^
./Main.cpp:23:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &temp);
                       ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt
All 0 / 300 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 1 ms 256 KB
in2.txt 20 ms 1400 KB
in3.txt 20 ms 1400 KB
in4.txt 20 ms 1400 KB
in5.txt 2 ms 256 KB
in6.txt 20 ms 1400 KB
in7.txt 18 ms 1400 KB
in8.txt 20 ms 1400 KB
sample1.txt 1 ms 256 KB
sample2.txt 1 ms 256 KB