231652026-01-16 15:05:41csicsilla70Osztozkodás (75 pont)cpp17Wrong answer 0/75600ms1332 KiB
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    //5
    //-2 3 -1 5 4
    //ANNA VALASZT ELOSZOR    5    4
    int N;
    cin >> N;
    int k;
    cin >> k;
    vector<int>szamok(N);

    int ANNA = 0;
    int BEA = 0;
    int kmaradhatranemvesziel = 0;
    int ellensegvesz = 0;
    int haelveszi = 0;

    for(int i = 0; i < N; i++){
        cin >> szamok[i];

    }
    int temp=0;
    for(int i=0; i<N; i++)
        for(int j=0; j<N-i-1; j++)
            if(szamok[j]<szamok[j+1]) {temp = szamok[j]; szamok[j] = szamok[j+1]; szamok[j+1] = temp;}
    for(int i=0; i<N; i++) cout << szamok[i]<<" ";
    cout <<endl;
    for(int i = 0; i < N-k; i++){ //k marad
        if(i%2==0) ANNA += szamok[i];
        else BEA += szamok[i];
        szamok[i] = 0;
    }
    int osszeg = 0;
    for(int i=N-k; i<N; i++) { //maradék
        osszeg = 0;
        for(int j=i; j<N;j++) osszeg += szamok[j];
        if(szamok[i] > osszeg){
            if(i%2==0) ANNA += szamok[i];
            else BEA += szamok[i];
            szamok[i]=0;
        } else {
            if(i%2==0) ANNA += osszeg;
            else BEA += osszeg;
            break;
        }
    }

    /*if(k % 2 == 1){
        for(int i = 0; i <=k-1; i+=2){ // 3    1 3  ha paratlan
            kmaradhatranemvesziel += szamok[i];
            ellensegvesz += szamok[i-1];
        }
    }else{
        for(int i = 1; i <= k-1; i+=2){// 4     2   4  h paros
                kmaradhatranemvesziel += szamok[i]; // pl 2 4
                 ellensegvesz += szamok[i-1]; //pl 1 3

        }
    }
    bool ANNATURN = true;
    bool BEATURN = false;
    int ANNAVESZ = N;
    int BEAVESZ = N-1;
    int j = N-1;

        while(j >= 0){
            if(j+1 == k){
                if(kmaradhatranemvesziel >= haelveszi){
                    if(ANNATURN){
                        ANNA += kmaradhatranemvesziel;
                        BEA += ellensegvesz;
                        j = -1;
                    }else{
                        BEA += kmaradhatranemvesziel;
                        ANNA += ellensegvesz;
                        j = -1;
                    }
                }else{
                    if(ANNATURN){
                        ANNA += haelveszi;
                        j = -1;

                    }else{
                        BEA += haelveszi;
                        j=-1;
                    }

                }
            }else if(ANNATURN){
                ANNA += szamok[j];
                j--;
                BEATURN = true;
                ANNATURN = false;

            }else if(BEATURN){
                BEA += szamok[j];
                j--;
                ANNATURN = true;
                BEATURN = false;

            }
        }
*/

    cout << ANNA << " "<<BEA;
    return 0;



}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/31ms316 KiB
5Wrong answer0/31ms332 KiB
6Wrong answer0/214ms404 KiB
7Wrong answer0/328ms316 KiB
8Wrong answer0/228ms416 KiB
9Wrong answer0/328ms412 KiB
10Wrong answer0/228ms416 KiB
11Wrong answer0/328ms420 KiB
12Time limit exceeded0/1598ms564 KiB
13Time limit exceeded0/2600ms808 KiB
14Time limit exceeded0/1586ms844 KiB
15Time limit exceeded0/2597ms1076 KiB
16Time limit exceeded0/1589ms760 KiB
17Time limit exceeded0/2595ms1172 KiB
18Time limit exceeded0/1600ms564 KiB
19Time limit exceeded0/2579ms1076 KiB
20Time limit exceeded0/2582ms564 KiB
21Time limit exceeded0/3597ms820 KiB
22Time limit exceeded0/2600ms564 KiB
23Time limit exceeded0/3600ms1332 KiB
24Time limit exceeded0/2582ms564 KiB
25Time limit exceeded0/3600ms564 KiB
26Time limit exceeded0/2597ms844 KiB
27Time limit exceeded0/3574ms564 KiB
28Time limit exceeded0/2582ms820 KiB
29Time limit exceeded0/3600ms564 KiB
30Wrong answer0/31ms508 KiB
31Wrong answer0/31ms316 KiB
32Wrong answer0/31ms564 KiB
33Wrong answer0/31ms316 KiB
34Wrong answer0/31ms508 KiB