Submission #1613370
Source Code Expand
#include <iostream> #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++) { cin >> 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 | 733 Byte |
Status | AC |
Exec Time | 51 ms |
Memory | 640 KB |
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 | 45 ms | 640 KB |
b06 | AC | 48 ms | 640 KB |
b07 | AC | 49 ms | 640 KB |
b08 | AC | 49 ms | 640 KB |
b09 | AC | 42 ms | 640 KB |
b10 | AC | 42 ms | 640 KB |
b11 | AC | 43 ms | 640 KB |
b12 | AC | 43 ms | 640 KB |
b13 | AC | 51 ms | 640 KB |