Submission #936955

# Submission time Handle Problem Language Result Execution time Memory
936955 2024-03-03T05:59:13 Z qwe1rt1yuiop1 Topical (NOI23_topical) C++14
61 / 100
1000 ms 140512 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
using pii = pair<int, int>;

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<vector<int>> a(n, vector<int>(k)), b = a;
    for (auto &i : a)
        for (auto &j : i)
            cin >> j;
    for (auto &i : b)
        for (auto &j : i)
            cin >> j;
    
    if (k == 1)
    {
        vector<pii> v(n);
        for (int i = 0; i < n; ++i)
            v[i].first = a[i][0], v[i].second = b[i][0];
        sort(v.begin(), v.end());
        int cur = 0, ans = 0;
        for (int i = 0; i < n; ++i)
            if (v[i].first <= cur)
            {
                cur += v[i].second;
                ++ans;
            }
        cout << ans << '\n';
        return;
    }
    
    vector<int> cur(k, 0), flag(n, 0);
    while (1)
    {
        int ok = 0;
        for (int i = 0; i < n; ++i)
            if (!flag[i])
            {
                int okk = 1;
                for (int j = 0; j < k; ++j)
                    okk &= cur[j] >= a[i][j];
                if (okk)
                {
                    ok = flag[i] = 1;
                    for (int j = 0; j < k; ++j)
                        cur[j] += b[i][j];
                    break;
                }
            }
        if (!ok)
            break;
    }
    cout << accumulate(flag.begin(), flag.end(), 0LL) << '\n';
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 113 ms 23788 KB Output is correct
5 Correct 123 ms 23796 KB Output is correct
6 Correct 111 ms 23748 KB Output is correct
7 Correct 93 ms 23776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 4 ms 1884 KB Output is correct
4 Correct 31 ms 14236 KB Output is correct
5 Correct 33 ms 14244 KB Output is correct
6 Correct 310 ms 140352 KB Output is correct
7 Correct 294 ms 138968 KB Output is correct
8 Correct 306 ms 140512 KB Output is correct
9 Correct 301 ms 139060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 113 ms 23788 KB Output is correct
5 Correct 123 ms 23796 KB Output is correct
6 Correct 111 ms 23748 KB Output is correct
7 Correct 93 ms 23776 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 3 ms 860 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 4 ms 1884 KB Output is correct
23 Correct 31 ms 14236 KB Output is correct
24 Correct 33 ms 14244 KB Output is correct
25 Correct 310 ms 140352 KB Output is correct
26 Correct 294 ms 138968 KB Output is correct
27 Correct 306 ms 140512 KB Output is correct
28 Correct 301 ms 139060 KB Output is correct
29 Correct 170 ms 34088 KB Output is correct
30 Correct 283 ms 33616 KB Output is correct
31 Execution timed out 1095 ms 39660 KB Time limit exceeded
32 Halted 0 ms 0 KB -