Submission #763547

# Submission time Handle Problem Language Result Execution time Memory
763547 2023-06-22T12:41:59 Z hariaakas646 Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
1207 ms 12424 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;

ld inf = 1e9;

bool cmp(pair<ld, ld> x, pair<ld, ld> y)
{
    return x.s < y.s;
}

int main()
{
    int n, k;
    scd(n);
    scd(k);

    vector<vector<ld>> prev(k + 1, vector<ld>(k + 2, inf)), curr(k + 1, vector<ld>(k + 2, inf));
    vector<pair<ld, ld>> vec(n);
    frange(i, n)
    {
        cin >> vec[i].f >> vec[i].s;
        if (vec[i].s == -1)
            vec[i].s = inf;
    }
    sort(all(vec), cmp);
    prev[0][1] = 0;
    prev[1][1] = vec[0].f;
    if (vec[0].s != inf)
        prev[1][2] = vec[0].s;

    forr(i, 1, n)
    {
        curr = vector<vector<ld>>(k + 1, vector<ld>(k + 2, inf));
        curr[0][1] = 0;
        forr(j, 1, k + 1)
        {
            forr(l, 1, j + 2)
            {
                curr[j][l] = min(prev[j][l], prev[j - 1][l] + vec[i].f / ld(l));
                if (l >= 2 && vec[i].s != inf)
                {
                    curr[j][l] = min(curr[j][l], prev[j - 1][l - 1] + vec[i].s / ld(l - 1));
                }
            }
        }
        prev = curr;
    }
    cout << fixed << setprecision(3) << *min_element(all(prev[k]));
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:45:5: note: in expansion of macro 'scd'
   45 |     scd(n);
      |     ^~~
Main.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:46:5: note: in expansion of macro 'scd'
   46 |     scd(k);
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 340 KB Output is correct
6 Correct 57 ms 980 KB Output is correct
7 Correct 221 ms 3324 KB Output is correct
8 Correct 503 ms 7048 KB Output is correct
9 Correct 906 ms 12272 KB Output is correct
10 Correct 430 ms 6228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 340 KB Output is correct
6 Correct 57 ms 980 KB Output is correct
7 Correct 221 ms 3324 KB Output is correct
8 Correct 503 ms 7048 KB Output is correct
9 Correct 906 ms 12272 KB Output is correct
10 Correct 430 ms 6228 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 100 ms 1416 KB Output is correct
13 Correct 92 ms 1844 KB Output is correct
14 Correct 82 ms 1420 KB Output is correct
15 Correct 556 ms 6184 KB Output is correct
16 Correct 508 ms 6236 KB Output is correct
17 Correct 457 ms 6228 KB Output is correct
18 Correct 1202 ms 12280 KB Output is correct
19 Correct 1130 ms 12380 KB Output is correct
20 Correct 1004 ms 12304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1207 ms 12424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 340 KB Output is correct
6 Correct 57 ms 980 KB Output is correct
7 Correct 221 ms 3324 KB Output is correct
8 Correct 503 ms 7048 KB Output is correct
9 Correct 906 ms 12272 KB Output is correct
10 Correct 430 ms 6228 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 100 ms 1416 KB Output is correct
13 Correct 92 ms 1844 KB Output is correct
14 Correct 82 ms 1420 KB Output is correct
15 Correct 556 ms 6184 KB Output is correct
16 Correct 508 ms 6236 KB Output is correct
17 Correct 457 ms 6228 KB Output is correct
18 Correct 1202 ms 12280 KB Output is correct
19 Correct 1130 ms 12380 KB Output is correct
20 Correct 1004 ms 12304 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 296 KB Output is correct
26 Correct 1 ms 300 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Incorrect 1 ms 212 KB Output isn't correct
30 Halted 0 ms 0 KB -