답안 #763544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763544 2023-06-22T12:40:09 Z hariaakas646 Let's Win the Election (JOI22_ho_t3) C++17
5 / 100
1167 ms 12268 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;
    }
    sort(all(vec), cmp);
    prev[0][1] = 0;
    prev[1][1] = vec[0].f;
    if (vec[0].s != -1)
        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 != -1)
                {
                    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 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 424 KB Output is correct
6 Correct 50 ms 980 KB Output is correct
7 Correct 207 ms 3412 KB Output is correct
8 Correct 475 ms 7064 KB Output is correct
9 Correct 904 ms 12268 KB Output is correct
10 Correct 416 ms 6348 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 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 424 KB Output is correct
6 Correct 50 ms 980 KB Output is correct
7 Correct 207 ms 3412 KB Output is correct
8 Correct 475 ms 7064 KB Output is correct
9 Correct 904 ms 12268 KB Output is correct
10 Correct 416 ms 6348 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 96 ms 1420 KB Output is correct
13 Incorrect 86 ms 1512 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1167 ms 12252 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 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 424 KB Output is correct
6 Correct 50 ms 980 KB Output is correct
7 Correct 207 ms 3412 KB Output is correct
8 Correct 475 ms 7064 KB Output is correct
9 Correct 904 ms 12268 KB Output is correct
10 Correct 416 ms 6348 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 96 ms 1420 KB Output is correct
13 Incorrect 86 ms 1512 KB Output isn't correct
14 Halted 0 ms 0 KB -