Submission #893330

# Submission time Handle Problem Language Result Execution time Memory
893330 2023-12-27T02:06:59 Z vjudge1 Topical (NOI23_topical) C++17
100 / 100
420 ms 143440 KB
#include <bits/stdc++.h>
#define task "60131A"
#define ff first
#define ss second
using namespace std;
using ld = long double;
using ull = unsigned long long;
using ll = long long;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
const char el = '\n';
const char sp = ' ';
const ll inf = 1e9; //1e18;
const ll maxN = 1e6 + 1;
int n, m;
int l[maxN], cnt[maxN];
ll p[maxN];
vector <vector <ll>> a, b;
vector <vector <pll>> c;
deque <int> dq;

int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen(task".inp", "r", stdin);
//    freopen(task".out", "w", stdout);
    cin >> n >> m;
    a.resize(n, vector <ll> (m));
    b.resize(n, vector <ll> (m));
    for (int i = 0;i < n;++i)
    {
        bool ok = 1;
        for (int j = 0;j < m;++j)
        {
            cin >> a[i][j];
            ok &= (a[i][j] == 0);
        }
        if (ok) dq.push_back(i), cnt[i] = inf;
    }
    for (int i = 0;i < n;++i)
        for (int j = 0;j < m;++j)
            cin >> b[i][j];
    c.resize(m, vector <pll> (n));
    for (int j = 0;j < m;++j)
    {
        l[j] = 0;
        for (int i = 0;i < n;++i)
            c[j][i] = {a[i][j], i};
        sort(c[j].begin(), c[j].end());
    }
    int ans = 0;
    while(!dq.empty())
    {
        auto it = dq.front();
        ans++;
        dq.pop_front();
        int i = it;
        for (int j = 0;j < m;++j)
            p[j] += b[i][j];
        for (int j = 0;j < m;++j)
        {
            while(l[j] < n && c[j][l[j]].ff <= p[j])
            {
                int ii = c[j][l[j]].ss;
                cnt[ii]++;
                if (cnt[ii] == m) dq.push_back(ii);
                l[j]++;
            }
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 2 ms 3008 KB Output is correct
4 Correct 162 ms 84632 KB Output is correct
5 Correct 160 ms 84356 KB Output is correct
6 Correct 168 ms 84424 KB Output is correct
7 Correct 130 ms 75976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 3 ms 4728 KB Output is correct
8 Correct 3 ms 4700 KB Output is correct
9 Correct 3 ms 4696 KB Output is correct
10 Correct 3 ms 4700 KB Output is correct
11 Correct 3 ms 4700 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 4 ms 5820 KB Output is correct
4 Correct 37 ms 16960 KB Output is correct
5 Correct 32 ms 16960 KB Output is correct
6 Correct 420 ms 143344 KB Output is correct
7 Correct 359 ms 143336 KB Output is correct
8 Correct 390 ms 143332 KB Output is correct
9 Correct 356 ms 143440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 2 ms 3008 KB Output is correct
4 Correct 162 ms 84632 KB Output is correct
5 Correct 160 ms 84356 KB Output is correct
6 Correct 168 ms 84424 KB Output is correct
7 Correct 130 ms 75976 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 4440 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 3 ms 4728 KB Output is correct
15 Correct 3 ms 4700 KB Output is correct
16 Correct 3 ms 4696 KB Output is correct
17 Correct 3 ms 4700 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 4 ms 5820 KB Output is correct
23 Correct 37 ms 16960 KB Output is correct
24 Correct 32 ms 16960 KB Output is correct
25 Correct 420 ms 143344 KB Output is correct
26 Correct 359 ms 143336 KB Output is correct
27 Correct 390 ms 143332 KB Output is correct
28 Correct 356 ms 143440 KB Output is correct
29 Correct 196 ms 36372 KB Output is correct
30 Correct 199 ms 35924 KB Output is correct
31 Correct 251 ms 43576 KB Output is correct
32 Correct 153 ms 36180 KB Output is correct
33 Correct 166 ms 35924 KB Output is correct
34 Correct 200 ms 36968 KB Output is correct
35 Correct 235 ms 43716 KB Output is correct
36 Correct 198 ms 37028 KB Output is correct
37 Correct 221 ms 36972 KB Output is correct
38 Correct 157 ms 43576 KB Output is correct