Submission #997284

# Submission time Handle Problem Language Result Execution time Memory
997284 2024-06-12T01:59:06 Z cpptowin Topical (NOI23_topical) C++17
100 / 100
562 ms 212636 KB
#include <bits/stdc++.h>
#define fo(i, d, c) for (int i = d; i <= c; i++)
#define fod(i, c, d) for (int i = c; i >= d; i--)
#define maxn 1000010
#define N 1010
#define fi first
#define se second
#define pb emplace_back
#define en cout << "\n";
#define int long long
#define inf (int)1e18
#define pii pair<int, int>
#define vii vector<pii>
#define lb(x) x & -x
#define bit(i, j) ((i >> j) & 1)
#define offbit(i, j) (i ^ (1LL << j))
#define onbit(i, j) (i | (1LL << j))
#define vi vector<int>
#define all(x) x.begin(), x.end()
template <typename T1, typename T2>
bool minimize(T1 &a, T2 b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool maximize(T1 &a, T2 b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
const int nsqrt = 450;
const int mod = 1e9 + 7;
vector<vi> r, u;
struct cmp
{
    bool operator()(array<int, 3> a, array<int, 3> b)
    {
        return a[0] > b[0] or (a[0] == b[0] and a > b);
    }
};
int n, k, cnt[maxn], p[maxn];
main()
{
#define name "TASK"
    if (fopen(name ".inp", "r"))
    {
        freopen(name ".inp", "r", stdin);
        freopen(name ".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    r.resize(n + 5);
    u.resize(n + 5);
    priority_queue<pii, vii, greater<pii>> q[k + 1];
    fo(i, 1, n)
    {
        cnt[i] = k;
        r[i].resize(k + 5);
        u[i].resize(k + 5);
    }
    fo(i, 1, n) fo(j, 1, k)
    {
        cin >> r[i][j];
        q[j].push({r[i][j], i});
    }
    fo(i, 1, n) fo(j, 1, k) cin >> u[i][j];
    int ans = 0;
    int clear = n;
    while(1)
    {
        int cancel = 0;
        fo(i, 1, k)
        {
            if (q[i].size())
            {
                auto [val, x] = q[i].top();
                if (p[i] >= val)
                    cnt[x]--, q[i].pop();
                else
                    cancel++;
                if (cnt[x] == 0)
                {
                    ans++;
                    fo(j, 1, k) p[j] += u[x][j];
                }
            }
            else
                cancel++;
        }
        if (cancel == k)
            return cout << ans, 0;
    }
}

Compilation message

Main.cpp:52:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 | main()
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:79:9: warning: unused variable 'clear' [-Wunused-variable]
   79 |     int clear = n;
      |         ^~~~~
Main.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen(name ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:58:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen(name ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 3420 KB Output is correct
4 Correct 157 ms 98568 KB Output is correct
5 Correct 160 ms 98640 KB Output is correct
6 Correct 161 ms 98604 KB Output is correct
7 Correct 128 ms 86608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2516 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 3 ms 2908 KB Output is correct
8 Correct 3 ms 2904 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 3 ms 2908 KB Output is correct
12 Correct 2 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 4 ms 4700 KB Output is correct
4 Correct 36 ms 24844 KB Output is correct
5 Correct 34 ms 24528 KB Output is correct
6 Correct 561 ms 212528 KB Output is correct
7 Correct 515 ms 211036 KB Output is correct
8 Correct 562 ms 212636 KB Output is correct
9 Correct 533 ms 211120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 3420 KB Output is correct
4 Correct 157 ms 98568 KB Output is correct
5 Correct 160 ms 98640 KB Output is correct
6 Correct 161 ms 98604 KB Output is correct
7 Correct 128 ms 86608 KB Output is correct
8 Correct 0 ms 2516 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 3 ms 2908 KB Output is correct
15 Correct 3 ms 2904 KB Output is correct
16 Correct 2 ms 2908 KB Output is correct
17 Correct 2 ms 2908 KB Output is correct
18 Correct 3 ms 2908 KB Output is correct
19 Correct 2 ms 2908 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 4 ms 4700 KB Output is correct
23 Correct 36 ms 24844 KB Output is correct
24 Correct 34 ms 24528 KB Output is correct
25 Correct 561 ms 212528 KB Output is correct
26 Correct 515 ms 211036 KB Output is correct
27 Correct 562 ms 212636 KB Output is correct
28 Correct 533 ms 211120 KB Output is correct
29 Correct 229 ms 56708 KB Output is correct
30 Correct 257 ms 51536 KB Output is correct
31 Correct 305 ms 65372 KB Output is correct
32 Correct 191 ms 47464 KB Output is correct
33 Correct 275 ms 44372 KB Output is correct
34 Correct 252 ms 48168 KB Output is correct
35 Correct 269 ms 61892 KB Output is correct
36 Correct 249 ms 51240 KB Output is correct
37 Correct 262 ms 54060 KB Output is correct
38 Correct 233 ms 54100 KB Output is correct