Submission #2139588
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}
int nextInt() { int x; scanf("%d", &x); return x;}
const int MAX_N = 105;
int D[MAX_N];
int main2() {
int N = nextInt();
ll A = nextInt();
ll B = nextInt();
ll C = nextInt();
REP(i, N) D[i] = nextInt();
sort(D, D+N);
reverse(D, D+N);
ll value = C;
ll price = A;
ll best = value / price;
REP(i, N) {
value += D[i];
price += B;
chmax(best, value / price);
}
cout << best << endl;
return 0;
}
int naive() {
int N = nextInt();
ll A = nextInt();
ll B = nextInt();
ll C = nextInt();
REP(i, N) D[i] = nextInt();
ll best = 0;
REP(set, (1 << N)) {
ll value = C;
ll price = A;
REP(i, N) if ((set >> i) & 1) {
value += D[i];
price += B;
}
chmax(best, value / price);
}
cout << best << endl;
return 0;
}
int main() {
for (;!cin.eof();cin>>ws)
// naive();
main2();
return 0;
}
Submission Info
Submission Time
2018-02-27 11:19:16+0900
Task
C - 最高のピザ (Best Pizza)
User
hs484
Language
C++14 (GCC 5.4.1)
Score
100
Code Size
1459 Byte
Status
AC
Exec Time
1 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int nextInt()’:
./Main.cpp:14:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int nextInt() { int x; scanf("%d", &x); return x;}
^
Judge Result
Set Name
set01
set02
set03
set04
set05
Score / Max Score
20 / 20
20 / 20
20 / 20
20 / 20
20 / 20
Status
Set Name
Test Cases
set01
data1
set02
data2
set03
data3
set04
data4
set05
data5
Case Name
Status
Exec Time
Memory
data1
AC
1 ms
256 KB
data2
AC
1 ms
256 KB
data3
AC
1 ms
256 KB
data4
AC
1 ms
256 KB
data5
AC
1 ms
256 KB