답안 #763549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763549 2023-06-22T12:45:07 Z hariaakas646 Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
1380 ms 12468 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 (int(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);
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 9 ms 428 KB Output is correct
6 Correct 67 ms 1072 KB Output is correct
7 Correct 221 ms 3324 KB Output is correct
8 Correct 522 ms 7072 KB Output is correct
9 Correct 1065 ms 12328 KB Output is correct
10 Correct 440 ms 6248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 9 ms 428 KB Output is correct
6 Correct 67 ms 1072 KB Output is correct
7 Correct 221 ms 3324 KB Output is correct
8 Correct 522 ms 7072 KB Output is correct
9 Correct 1065 ms 12328 KB Output is correct
10 Correct 440 ms 6248 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 101 ms 1424 KB Output is correct
13 Correct 93 ms 1420 KB Output is correct
14 Correct 89 ms 1868 KB Output is correct
15 Correct 573 ms 6292 KB Output is correct
16 Correct 515 ms 6232 KB Output is correct
17 Correct 460 ms 6244 KB Output is correct
18 Correct 1380 ms 12276 KB Output is correct
19 Correct 1185 ms 12376 KB Output is correct
20 Correct 1028 ms 12468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Incorrect 1 ms 300 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Incorrect 1 ms 300 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Incorrect 1 ms 300 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1265 ms 12248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 9 ms 428 KB Output is correct
6 Correct 67 ms 1072 KB Output is correct
7 Correct 221 ms 3324 KB Output is correct
8 Correct 522 ms 7072 KB Output is correct
9 Correct 1065 ms 12328 KB Output is correct
10 Correct 440 ms 6248 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 101 ms 1424 KB Output is correct
13 Correct 93 ms 1420 KB Output is correct
14 Correct 89 ms 1868 KB Output is correct
15 Correct 573 ms 6292 KB Output is correct
16 Correct 515 ms 6232 KB Output is correct
17 Correct 460 ms 6244 KB Output is correct
18 Correct 1380 ms 12276 KB Output is correct
19 Correct 1185 ms 12376 KB Output is correct
20 Correct 1028 ms 12468 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 296 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Incorrect 1 ms 300 KB Output isn't correct
30 Halted 0 ms 0 KB -