Submission #914154

# Submission time Handle Problem Language Result Execution time Memory
914154 2024-01-21T09:59:59 Z Litusiano Topical (NOI23_topical) C++17
100 / 100
551 ms 144152 KB
	#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
	#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
	#include<bits/stdc++.h>
	using namespace std;
	#define int long long

	bool cmp(pair<int,int> a, pair<int,int> b){
		return a.second < b.second;
	}

	signed main(){
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		int n,k; cin>>n>>k;
		vector<vector<int>> r(n,vector<int>(k,0)); auto u = r;
		for(auto& x : r){
			for(auto& i : x) cin>>i;
		}
		for(auto& x : u){
			for(auto& i : x) cin>>i;
		}
		vector<vector<pair<int,int>>> idx(k);
		vector<int> pt(k);
		for(int i = 0; i<k; i++){
			for(int j = 0; j<n; j++){
				idx[i].push_back({r[j][i], j});
			}
			sort(idx[i].begin(), idx[i].end());
			// can go from i to i+1 if and only if in this topic if r[i][j] + u[i][j] >= r[z][j]   
		}
		queue<int> q; q.push(-1);
		vector<int> act(k); vector<int> used(n);
		vector<int> PT(k,0);
		int ans = 0;
		while(!q.empty()){
			int u1 = q.front(); q.pop();
			if(u1 >= 0) ans++;
			for(int i = 0; i<k; i++){
				if(u1 >= 0) act[i] += u[u1][i];
				if(PT[i] == n) continue;
				if(idx[i][PT[i]].first > act[i]) continue;
				while(PT[i] < n && idx[i][PT[i]].first <= act[i]){
					// cerr<<"! "<<i<<" "<<idx[i][PT[i]].second<<endl;
					used[idx[i][PT[i]].second]++;
					// if all used, q.push
					if(used[idx[i][PT[i]].second] == k) q.push(idx[i][PT[i]].second);
					PT[i]++;
				}
			}
		}
		
		cout<<ans<<endl;
	}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 1368 KB Output is correct
4 Correct 192 ms 100300 KB Output is correct
5 Correct 217 ms 100516 KB Output is correct
6 Correct 189 ms 100328 KB Output is correct
7 Correct 161 ms 97252 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 1 ms 504 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 3 ms 860 KB Output is correct
9 Correct 2 ms 720 KB Output is correct
10 Correct 3 ms 860 KB Output is correct
11 Correct 3 ms 860 KB Output is correct
12 Correct 3 ms 860 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 5 ms 2008 KB Output is correct
4 Correct 52 ms 14860 KB Output is correct
5 Correct 41 ms 14396 KB Output is correct
6 Correct 551 ms 144152 KB Output is correct
7 Correct 509 ms 140896 KB Output is correct
8 Correct 515 ms 144124 KB Output is correct
9 Correct 472 ms 140456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 1368 KB Output is correct
4 Correct 192 ms 100300 KB Output is correct
5 Correct 217 ms 100516 KB Output is correct
6 Correct 189 ms 100328 KB Output is correct
7 Correct 161 ms 97252 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 860 KB Output is correct
15 Correct 3 ms 860 KB Output is correct
16 Correct 2 ms 720 KB Output is correct
17 Correct 3 ms 860 KB Output is correct
18 Correct 3 ms 860 KB Output is correct
19 Correct 3 ms 860 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 5 ms 2008 KB Output is correct
23 Correct 52 ms 14860 KB Output is correct
24 Correct 41 ms 14396 KB Output is correct
25 Correct 551 ms 144152 KB Output is correct
26 Correct 509 ms 140896 KB Output is correct
27 Correct 515 ms 144124 KB Output is correct
28 Correct 472 ms 140456 KB Output is correct
29 Correct 237 ms 45864 KB Output is correct
30 Correct 242 ms 41000 KB Output is correct
31 Correct 353 ms 48716 KB Output is correct
32 Correct 176 ms 41376 KB Output is correct
33 Correct 211 ms 37456 KB Output is correct
34 Correct 245 ms 38200 KB Output is correct
35 Correct 293 ms 47176 KB Output is correct
36 Correct 242 ms 39796 KB Output is correct
37 Correct 272 ms 41156 KB Output is correct
38 Correct 198 ms 43352 KB Output is correct