Submission #855689

# Submission time Handle Problem Language Result Execution time Memory
855689 2023-10-01T16:28:44 Z mkorzybski Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
202 ms 604 KB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define f first
#define s second
#define ld long double
#define ll long long
 
 
int n, k, I;
const int N = 507;
int A[N], B[N];
vector <pii> vA;
ld odpowiedz;
bool wziete[N];
 
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    cin >> n >> k;
    for(int i=1; i<=n; i++)
    {
        cin >> A[i] >> B[i];
 
        if(B[i] != -1) I++;
        vA.push_back({A[i], i});
    }
    I = min(I, k);
    sort(vA.begin(), vA.end());
 
 
    for(int i=1; i<=k; i++)
    {
        odpowiedz += (ld) vA[i-1].f;
    }
 
 
    for(int i=1; i<=I; i++)
    {
        vector <pii> ciagA;
        for(int j=1; j<=n; j++) ciagA.push_back(vA[j-1]);
        ld wynik = 0;
        vector <ld> vBtmp;
 
        for(int j=1; j<=i; j++)
        {
            ld minWyn = 10000000;
            int kto = -1;
            for(int o=1; o<=n; o++)
            {
                if(wziete[o] or B[o] == -1) continue;
 
                ld tmp = ((ld) B[o] / (ld) j);
                if(A[o] <= ciagA[k-i-1].f) tmp += ((ld)(ciagA[k-i].f - A[o]) / (ld)(i+1));
 
                //cout << "tmp = " << ((ld)(ciagA[k-i].f - A[o]) / (ld)(i+1)) << endl;
                if(minWyn > tmp)
                {
                    minWyn = tmp;
                    kto = o;
                }
            }
 
            //cout << "kto = " << kto << endl;
            wziete[kto] = true;
            wynik += (ld) B[kto] /(ld) j;
            vBtmp.push_back((ld)B[kto]);
            int tmpSize = ciagA.size();
            for(int o=0; o<tmpSize; o++)
            {
                pii v = ciagA[o];
                if(v.s == kto)
                {
                    ciagA.erase(ciagA.begin() + o);
                }
            }
        }
 
        ld sumaA = 0;
        for(int j=1; j<=k-i; j++)
        {
            sumaA += (ld) ciagA[j-1].f;
        }
        sumaA /= (ld)(i+1);

        wynik = 0;
        ld licznik = 1;
        sort(vBtmp.begin(), vBtmp.end());
        for(ld v : vBtmp)
        {
            wynik += v / licznik;
            licznik = licznik + (ld) 1;
        }

        odpowiedz = min(odpowiedz, wynik + sumaA);
        //cout << "wynik " << i << " = " << wynik << ", suma = " << sumaA << endl;
        for(int j=1; j<=n; j++) wziete[j] = false;
    }
 
    cout << fixed << setprecision(7) << odpowiedz;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 18 ms 476 KB Output is correct
13 Correct 18 ms 472 KB Output is correct
14 Correct 7 ms 348 KB Output is correct
15 Correct 98 ms 472 KB Output is correct
16 Correct 61 ms 456 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 202 ms 460 KB Output is correct
19 Correct 75 ms 476 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Incorrect 0 ms 460 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Incorrect 0 ms 460 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Incorrect 0 ms 460 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 197 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 18 ms 476 KB Output is correct
13 Correct 18 ms 472 KB Output is correct
14 Correct 7 ms 348 KB Output is correct
15 Correct 98 ms 472 KB Output is correct
16 Correct 61 ms 456 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 202 ms 460 KB Output is correct
19 Correct 75 ms 476 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 0 ms 600 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 360 KB Output is correct
32 Correct 0 ms 604 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Incorrect 0 ms 460 KB Output isn't correct
36 Halted 0 ms 0 KB -