QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#142899#6389. TopicalaVe#12 325ms26540kbC++201.3kb2023-08-20 02:15:112024-07-04 02:40:45

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 02:40:45]
  • 评测
  • 测评结果:12
  • 用时:325ms
  • 内存:26540kb
  • [2023-08-20 02:15:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int main(){
	int n, k;
	cin>>n>>k;
	vector<vector<ll>> need(n, vector<ll>(k));
	vector<vector<ll>> gain(n, vector<ll>(k));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < k; j++)
			cin>>need[i][j];
	
	for(int i = 0; i < n; i++)
		for(int j = 0; j < k; j++)
			cin>>gain[i][j];
			
	bool vis[n];
	vi current(k, 0);
	memset(vis, false, sizeof vis);
	queue<int> q;
	for(int i = 0; i < n; i++){
		bool can = true;
		for(int j = 0; j < k; j++){
			if(need[i][j] > current[j]){
				can = false;
				break;
			}
		}
		if(can && !vis[i]){
			q.push(i);
			vis[i] = true;
		}
	}
//	cout<<"HERE"<<endl;
	int ans = 0;
	while(!q.empty()){
		int at = q.front();
		q.pop();
		ans++;
//		cout<<at+1<<endl;
		for(int j = 0; j < k; j++){
			current[j] += gain[at][j];
		}
		for(int i = 0; i < n; i++){
			if(vis[i])	continue;
			bool can_now = true;
			for(int j = 0; j < k; j++){
				if(need[i][j] > current[j]){
					can_now = false;
					break;
				}
			}
			if(can_now && !vis[i]){
				q.push(i);
				vis[i] = true;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 12
Accepted

Test #1:

score: 12
Accepted
time: 0ms
memory: 3544kb

input:

1 1
693647287
340782526

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1 100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
279985824 991797187 998715443 98505529 106002744 636773096 815089164 196160830 796988849 87975...

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 4ms
memory: 3760kb

input:

1 10000
841961872 0 0 0 0 0 0 0 0 0 0 0 0 0 831386430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 205210920 705123207 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 276768098 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 661649446 0 0 0 0 0 0 0 0 0 0 ...

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 324ms
memory: 26452kb

input:

1 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 321ms
memory: 26496kb

input:

1 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 325ms
memory: 26540kb

input:

1 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 199ms
memory: 26468kb

input:

1 1000000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 10...

output:

0

result:

ok 1 number(s): "0"

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 28
Accepted
time: 0ms
memory: 3520kb

input:

100 1
893339036
896783899
690308537
201770764
262364362
105000893
770698921
744238454
470980016
935046317
642998516
100481910
392307650
116783134
196939768
372329082
346372520
43063564
245523488
389084350
130314590
412588681
987795927
681635353
304582580
472268968
700147283
743357606
792644412
99955...

output:

85

result:

ok 1 number(s): "85"

Test #9:

score: -28
Wrong Answer
time: 5ms
memory: 3700kb

input:

100 100
1000000000 828788913 1000000000 894501902 1000000000 898513761 837197514 865900986 809812226 853486369 848261509 888902562 1000000000 881898651 932777249 907237990 892103882 1000000000 870206141 1000000000 776016734 1000000000 889438568 856689807 887799348 859324346 872070680 879391131 10000...

output:

42

result:

wrong answer 1st numbers differ - expected: '52', found: '42'

Subtask #3:

score: 0
Time Limit Exceeded

Test #15:

score: 21
Accepted
time: 151ms
memory: 4400kb

input:

10000 1
568857328
651788426
751475430
102940442
763289419
468657944
770847628
780257867
16919385
575963868
281824241
291248174
140016533
313529232
302186452
32709864
787073783
1926820
239509174
220454071
34252400
390385721
675239026
245106357
489697460
28435096
825528061
159083009
16370561
223299279...

output:

10000

result:

ok 1 number(s): "10000"

Test #16:

score: -21
Time Limit Exceeded

input:

100000 1
78763439
671847244
661890823
215179284
804182046
667280820
140277780
822235648
809998506
39559747
459311656
212179350
227573276
606854131
182676019
61302123
281509402
53785090
106827674
911115512
31998233
678388767
75425082
154920343
882021740
976962371
219500493
609794633
780392857
6696241...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%