AtCoder Grand Contest 011

Submission #1591373

Source codeソースコード

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <deque>
#include <queue>
#include <climits>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v) sort(v.begin(), v.end())
#define SORTFUNC(v, func) sort(v.begin(), v.end(), func)
#define PRINT(v) REP(i, v.size()) printf("%d ", v[i]); cout << endl
#define IN(n) scanf("%d", &(n))

int main(){
  int n, c, k;
  IN(n); IN(c); IN(k);
  vector<int> tab(n);
  REP(i, n) IN(tab[i]);
  SORT(tab);

  int res = 0, people = 0, starttime = tab[0];
  REP(i, n){
    if (people == c){
      res++;
      people = 1;
      starttime = tab[i];
    }
    else {
      if(tab[i] > starttime+k){
        res++;
        people = 1;
        starttime = tab[i];
      }
      else people++;
    }
    //printf("people = %d, res = %d, startime = %d\n", people, res, starttime);
  }
  if(people > 0) res++;
  printf("%d\n", res);
  return 0;
}
























// I'd like to scroll past the end of document using Atom but I seemigly have to use these blank lines instead

Submission

Task問題 A - Airport Bus
User nameユーザ名 iocto
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 300
Source lengthソースコード長 1357 Byte
File nameファイル名
Exec time実行時間 19 ms
Memory usageメモリ使用量 640 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
IN(n); IN(c); IN(k);
^
./Main.cpp:29:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
IN(n); IN(c); IN(k);
^
./Main.cpp:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
IN(n); IN(c); IN(k);
^
./Main.cpp:31:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i, n) IN(tab[i]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample1.txt,sample2.txt
All 300 / 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
in1.txt AC 1 ms 256 KB
in2.txt AC 18 ms 640 KB
in3.txt AC 18 ms 640 KB
in4.txt AC 18 ms 640 KB
in5.txt AC 1 ms 256 KB
in6.txt AC 19 ms 640 KB
in7.txt AC 16 ms 640 KB
in8.txt AC 19 ms 640 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB