Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void swap(int *xp, int *yp) {
- int temp = *xp;
- *xp = *yp;
- *yp = temp;
- }
- void bubbleSort(int M[], int N) {
- int i, j;
- for (i = 0; i < N-1; i++) {
- for (j = 0; j < N-i-1; j++) {
- if (M[j] > M[j+1]) {
- swap(&M[j], &M[j+1]);
- }
- }
- }
- }
- int main () {
- int N,A,B,C;
- int MusuhDikalahkan = 0; int SuperDigunakan = 0;
- cin >> N >> A >> B >> C;
- int M[N];
- for (auto i {0}; i < N; i++) {
- cin >> M[i];
- }
- bubbleSort(M,N);
- for (auto i {0}; i < N; i++) {
- lawan:
- if (A >= M[i]) {
- A = A*C;
- MusuhDikalahkan = MusuhDikalahkan + 1;
- }
- else if (SuperDigunakan == 1) {
- goto skip;
- }
- else if (A < M[i]) {
- A = A + B;
- SuperDigunakan = 0 + 1;
- goto lawan;
- }
- skip:
- continue;
- }
- cout << MusuhDikalahkan << " " << SuperDigunakan;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement