Submission #893318

# Submission time Handle Problem Language Result Execution time Memory
893318 2023-12-27T01:45:45 Z damwuan Topical (NOI23_topical) C++17
100 / 100
331 ms 110760 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define bit(n,i) ((n>>i)&1)
#define all(x) x.begin(),x.end()
#define int long long
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef double ld;
typedef pair<ld,ld> pdd;
typedef pair<ll,ll> pll;
const ll maxn=1e6+5;
const ll offset=2e5;
const ll blk=317;
const ll inf=1e9;
const int base =311;
const ll mod=998244353;
int n,k;
vector<vector<int>> u;
vector<pii> L[maxn];
int p[maxn],cnt[maxn];
void sol() {
    cin >> n>> k;
    u.resize(n+2,vector<int>(k+2,0));
    for1(i,1,n)
    {
        for1(j,1,k)
        {
            int x; cin >> x;
            L[j].pb({x,i});
        }
    }
    for1(i,1,n)
    {
        for1(j,1,k)
        {
            cin >> u[i][j];
        }
    }
    for1(j,1,k) sort(all(L[j]),greater<pii>());
    vector<int> qq;
    int res=0;
    while (true)
    {
        for1(j,1,k)
        {
            while (!L[j].empty() && p[j]>= L[j].back().fi)
            {
                cnt[L[j].back().se]++;
//            cerr<< cnt[L[j].back().se]<<' '<<L[j].back().se<<'\n';
                if (cnt[L[j].back().se] == k) qq.pb(L[j].back().se);
                L[j].pop_back();
            }
        }
//        cerr<< qq.size()<<'\n';
        if (qq.empty()) break;
        while (!qq.empty())
        {
            int i=qq.back();
            qq.pop_back();
            res++;
            for1(j,1,k) p[j]+=u[i][j];
        }
    }
    cout << res<<'\n';

}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("paleta.inp","r",stdin);
//    freopen("paleta.out","w",stdout);

    int t=1;//cin >> t;
    while (t--) {
        sol();
    }
}

/*
1
5 3
4 1 2 3 1
*/









# Verdict Execution time Memory Grader output
1 Correct 6 ms 24920 KB Output is correct
2 Correct 7 ms 25016 KB Output is correct
3 Correct 8 ms 25436 KB Output is correct
4 Correct 188 ms 86472 KB Output is correct
5 Correct 202 ms 86544 KB Output is correct
6 Correct 194 ms 86512 KB Output is correct
7 Correct 158 ms 79636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 25176 KB Output is correct
2 Correct 6 ms 24924 KB Output is correct
3 Correct 6 ms 24924 KB Output is correct
4 Correct 6 ms 24924 KB Output is correct
5 Correct 6 ms 24888 KB Output is correct
6 Correct 6 ms 24924 KB Output is correct
7 Correct 8 ms 25180 KB Output is correct
8 Correct 7 ms 25180 KB Output is correct
9 Correct 8 ms 25380 KB Output is correct
10 Correct 8 ms 25180 KB Output is correct
11 Correct 8 ms 25180 KB Output is correct
12 Correct 7 ms 25180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 24920 KB Output is correct
2 Correct 6 ms 25048 KB Output is correct
3 Correct 8 ms 25948 KB Output is correct
4 Correct 33 ms 34292 KB Output is correct
5 Correct 33 ms 34240 KB Output is correct
6 Correct 308 ms 109992 KB Output is correct
7 Correct 331 ms 103592 KB Output is correct
8 Correct 304 ms 110760 KB Output is correct
9 Correct 329 ms 103320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 24920 KB Output is correct
2 Correct 7 ms 25016 KB Output is correct
3 Correct 8 ms 25436 KB Output is correct
4 Correct 188 ms 86472 KB Output is correct
5 Correct 202 ms 86544 KB Output is correct
6 Correct 194 ms 86512 KB Output is correct
7 Correct 158 ms 79636 KB Output is correct
8 Correct 7 ms 25176 KB Output is correct
9 Correct 6 ms 24924 KB Output is correct
10 Correct 6 ms 24924 KB Output is correct
11 Correct 6 ms 24924 KB Output is correct
12 Correct 6 ms 24888 KB Output is correct
13 Correct 6 ms 24924 KB Output is correct
14 Correct 8 ms 25180 KB Output is correct
15 Correct 7 ms 25180 KB Output is correct
16 Correct 8 ms 25380 KB Output is correct
17 Correct 8 ms 25180 KB Output is correct
18 Correct 8 ms 25180 KB Output is correct
19 Correct 7 ms 25180 KB Output is correct
20 Correct 6 ms 24920 KB Output is correct
21 Correct 6 ms 25048 KB Output is correct
22 Correct 8 ms 25948 KB Output is correct
23 Correct 33 ms 34292 KB Output is correct
24 Correct 33 ms 34240 KB Output is correct
25 Correct 308 ms 109992 KB Output is correct
26 Correct 331 ms 103592 KB Output is correct
27 Correct 304 ms 110760 KB Output is correct
28 Correct 329 ms 103320 KB Output is correct
29 Correct 213 ms 53288 KB Output is correct
30 Correct 204 ms 48980 KB Output is correct
31 Correct 248 ms 56504 KB Output is correct
32 Correct 173 ms 53312 KB Output is correct
33 Correct 172 ms 49036 KB Output is correct
34 Correct 201 ms 52232 KB Output is correct
35 Correct 239 ms 56492 KB Output is correct
36 Correct 206 ms 52336 KB Output is correct
37 Correct 221 ms 52336 KB Output is correct
38 Correct 162 ms 56516 KB Output is correct