Submission #1865328


Source Code Expand

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector <ll> h;
  REP(i,n){
    ll c;
    cin >> c;
    h.pb(c);
  }
  ll num = 0;
  sort(h.begin(),h.end(),greater<ll>());
  while(1){
    ll s = a-b;
    ll t = h[0]-h[1];
    ll g = t/s;
    if(g > 0){
      h[0] -= a*g;
      h[1] -= b*g;
      num += g;
    }
    else{
      h[0] -= a;
      h[1] -= b;
      if(h[0] < h[1])
	swap(h[0],h[1]);
      num++;
    }
    
    if(h[0] <= 0)
      break;
  }
  cout << num << endl;
  return 0;
}

Submission Info

Submission Time
Task D - Widespread
User kodamune
Language C++14 (GCC 5.4.1)
Score 0
Code Size 758 Byte
Status WA
Exec Time 2103 ms
Memory 1528 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 2
TLE × 1
AC × 4
WA × 6
TLE × 3
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 TLE 2103 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 45 ms 1400 KB
b06 TLE 2103 ms 1528 KB
b07 WA 45 ms 1400 KB
b08 WA 45 ms 1400 KB
b09 TLE 2103 ms 1400 KB
b10 WA 221 ms 1400 KB
b11 WA 50 ms 1400 KB
b12 WA 47 ms 1400 KB
b13 WA 47 ms 1528 KB