Submission #1156420
Source Code Expand
#include<cstdio> #include<cstdlib> #include<cstring> #include<vector> #include<algorithm> #include<queue> using namespace std; int main(void){ vector<int> a; int b[100000]; int c; int k; long long s; int p, q; int n, m; int x, y, z; c = 0; s = 0; q = 0; z = 0; for (int i = 0; i < 100000; i++){ b[i] = 0; } scanf("%d %d %d", &n,&x,&y); for (int i = 0; i < n; i++){ scanf("%d", &k); a.push_back(k); } sort(a.begin(), a.end()); c = 1; p = 1; s = a[0] + y; for (int i = 1; i < n; i++){ if (p == x){ s = a[i] + y; p = 1; c++; } else if (s < a[i]){ s = a[i] + y; p = 1; c++; } else { p++; } } printf("%d\n",c); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Airport Bus |
User | mechanicalpenciI |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 737 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 892 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:27:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d %d", &n,&x,&y); ^ ./Main.cpp:29:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &k); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 20 ms | 892 KB |
in3.txt | AC | 20 ms | 892 KB |
in4.txt | AC | 20 ms | 892 KB |
in5.txt | AC | 2 ms | 256 KB |
in6.txt | AC | 20 ms | 892 KB |
in7.txt | AC | 18 ms | 892 KB |
in8.txt | AC | 20 ms | 892 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |