Submission #1613389
Source Code Expand
#include <iostream> #include <cstdio> #include <math.h> using namespace std; typedef long long LL; int N, A, B, h[(int)1e5]; bool judge(LL K) { LL sum = 0; for(int i = 0; i < N; i++) { LL t = (LL)h[i]-K*B; if (t > 0) { sum += (int)ceil(t*1.0/(A-B)); if(sum > K) return false; } } return true; } int main() { cin >> N >> A >> B; for (int i = 0; i < N; i++) scanf("%d", &h[i]); LL low = 0, high = (int)1e9; while (low < high) { LL mid = (low + high) / 2; if (judge(mid)) high = mid; else low = mid+1; } cout << low << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Widespread |
User | kira924age |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 759 Byte |
Status | AC |
Exec Time | 23 ms |
Memory | 640 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:28:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &h[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | a01, a02, a03 |
All | a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
a01 | AC | 1 ms | 256 KB |
a02 | AC | 1 ms | 256 KB |
a03 | AC | 1 ms | 256 KB |
b04 | AC | 1 ms | 256 KB |
b05 | AC | 15 ms | 640 KB |
b06 | AC | 17 ms | 640 KB |
b07 | AC | 19 ms | 640 KB |
b08 | AC | 18 ms | 640 KB |
b09 | AC | 14 ms | 640 KB |
b10 | AC | 14 ms | 640 KB |
b11 | AC | 16 ms | 640 KB |
b12 | AC | 16 ms | 640 KB |
b13 | AC | 23 ms | 640 KB |