# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
893319 |
2023-12-27T01:46:04 Z |
vjudge1 |
Topical (NOI23_topical) |
C++17 |
|
348 ms |
110392 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 |
5 ms |
24924 KB |
Output is correct |
2 |
Correct |
5 ms |
25016 KB |
Output is correct |
3 |
Correct |
8 ms |
25688 KB |
Output is correct |
4 |
Correct |
189 ms |
86684 KB |
Output is correct |
5 |
Correct |
199 ms |
86404 KB |
Output is correct |
6 |
Correct |
188 ms |
86444 KB |
Output is correct |
7 |
Correct |
161 ms |
80068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
24920 KB |
Output is correct |
2 |
Correct |
6 ms |
25032 KB |
Output is correct |
3 |
Correct |
6 ms |
24924 KB |
Output is correct |
4 |
Correct |
6 ms |
24920 KB |
Output is correct |
5 |
Correct |
6 ms |
24976 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 |
25176 KB |
Output is correct |
9 |
Correct |
8 ms |
25180 KB |
Output is correct |
10 |
Correct |
8 ms |
25180 KB |
Output is correct |
11 |
Correct |
8 ms |
25180 KB |
Output is correct |
12 |
Correct |
8 ms |
25184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
25176 KB |
Output is correct |
2 |
Correct |
6 ms |
25120 KB |
Output is correct |
3 |
Correct |
9 ms |
25884 KB |
Output is correct |
4 |
Correct |
35 ms |
34500 KB |
Output is correct |
5 |
Correct |
34 ms |
34244 KB |
Output is correct |
6 |
Correct |
306 ms |
110392 KB |
Output is correct |
7 |
Correct |
328 ms |
103336 KB |
Output is correct |
8 |
Correct |
301 ms |
110248 KB |
Output is correct |
9 |
Correct |
348 ms |
103672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
24924 KB |
Output is correct |
2 |
Correct |
5 ms |
25016 KB |
Output is correct |
3 |
Correct |
8 ms |
25688 KB |
Output is correct |
4 |
Correct |
189 ms |
86684 KB |
Output is correct |
5 |
Correct |
199 ms |
86404 KB |
Output is correct |
6 |
Correct |
188 ms |
86444 KB |
Output is correct |
7 |
Correct |
161 ms |
80068 KB |
Output is correct |
8 |
Correct |
6 ms |
24920 KB |
Output is correct |
9 |
Correct |
6 ms |
25032 KB |
Output is correct |
10 |
Correct |
6 ms |
24924 KB |
Output is correct |
11 |
Correct |
6 ms |
24920 KB |
Output is correct |
12 |
Correct |
6 ms |
24976 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 |
25176 KB |
Output is correct |
16 |
Correct |
8 ms |
25180 KB |
Output is correct |
17 |
Correct |
8 ms |
25180 KB |
Output is correct |
18 |
Correct |
8 ms |
25180 KB |
Output is correct |
19 |
Correct |
8 ms |
25184 KB |
Output is correct |
20 |
Correct |
5 ms |
25176 KB |
Output is correct |
21 |
Correct |
6 ms |
25120 KB |
Output is correct |
22 |
Correct |
9 ms |
25884 KB |
Output is correct |
23 |
Correct |
35 ms |
34500 KB |
Output is correct |
24 |
Correct |
34 ms |
34244 KB |
Output is correct |
25 |
Correct |
306 ms |
110392 KB |
Output is correct |
26 |
Correct |
328 ms |
103336 KB |
Output is correct |
27 |
Correct |
301 ms |
110248 KB |
Output is correct |
28 |
Correct |
348 ms |
103672 KB |
Output is correct |
29 |
Correct |
217 ms |
53332 KB |
Output is correct |
30 |
Correct |
207 ms |
49080 KB |
Output is correct |
31 |
Correct |
245 ms |
56512 KB |
Output is correct |
32 |
Correct |
170 ms |
53332 KB |
Output is correct |
33 |
Correct |
173 ms |
49232 KB |
Output is correct |
34 |
Correct |
200 ms |
52232 KB |
Output is correct |
35 |
Correct |
233 ms |
56516 KB |
Output is correct |
36 |
Correct |
202 ms |
52428 KB |
Output is correct |
37 |
Correct |
217 ms |
52232 KB |
Output is correct |
38 |
Correct |
155 ms |
56496 KB |
Output is correct |