답안 #950472

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
950472 2024-03-20T10:45:03 Z ALTAKEXE Jelly Flavours (IOI20_jelly) C++14
0 / 100
3 ms 600 KB
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<ll, ll>
ll const INF = LLONG_MAX;
using namespace std;
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b)
{
    ll n = a.size();
    vector<pii> v(n);
    for (ll i = 0; i < n; i++)
        v[i] = make_pair(a[i], b[i]);
    sort(v.begin(), v.end());
    vector<ll> dp;
    vector<ll> umn(x + 1, 0);
    umn[0] = 0;
    ll i;
    for (ll i = 0; i < n; i++)
    {
        ll ok = 0;
        dp = vector<ll>(x + 1, INF);
        ll A = v[i].f, B = v[i].s;
        for (ll j = 0; j <= x; j++)
        {
            dp[j] = umn[j] + B;
            if (j - A >= 0)
                dp[j] = min(dp[j], umn[j - A]);
            ok |= (dp[j] <= y);
        }
        if (!ok)
            break;
        swap(dp, umn);
    }
    return i;
}

Compilation message

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:35:12: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |     return i;
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '8', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '8', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '689', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 600 KB 1st lines differ - on the 1st token, expected: '62', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 600 KB 1st lines differ - on the 1st token, expected: '154', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '8', found: '0'
2 Halted 0 ms 0 KB -