QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201738#686. Bad DoctorwertRE 1ms9720kbC++141.7kb2023-10-05 16:32:122023-10-05 16:32:13

Judging History

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

  • [2023-10-05 16:32:13]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:9720kb
  • [2023-10-05 16:32:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace ac{
	const int MAXN = 5005;
	int n, m, c[MAXN], l[MAXN], r[MAXN], k[MAXN], x[MAXN][MAXN], eat[MAXN][MAXN], mxr;
	struct node{
		int l, r;
	}fk[500005];
	long long nmb[500005];
	long long getans(){
		long long ans = 0;
		for(int i = 1;i <= mxr;i++){
			for(int j = 1;j <= m;j++){
				if(eat[i][j]) ans += 1ll * c[j]; 
			}
		}return ans;
	}
	bool cmp(node a, node b){
		return a.l < b.l;
	}
	bool pd(){
		sort(fk + 1, fk + n + 1, cmp);
		for(int i = 2;i <= n;i++){
			if(fk[i].l <= fk[i - 1].r) return 0;
		}return 1;
	}
	void solve(){
		long long fks = 0;
		for(int i = 1;i <= n;i++){
			fks += nmb[i];
		}
		for(int i = 1;i <= n;i++){
			printf("%lld ", fks - nmb[i]);
		}
	}
	int main(){
		scanf("%d%d", &n, &m);
		for(int i = 1;i <= m;i++) scanf("%d", &c[i]);
		for(int i = 1;i <= n;i++){
			scanf("%d%d%d", &l[i], &r[i], &k[i]);
			mxr = max(mxr, r[i]);
			fk[i].l = l[i];
			fk[i].r = r[i];
			for(int j = 1;j <= k[i];j++){
				scanf("%d", &x[i][j]);
				nmb[i] += 1ll * (r[i] - l[i] + 1) * c[x[i][j]];
			}
		}
		if(pd()){
			solve();
			return 0;
		}
		for(int by = 1;by <= n;by++){
			for(int i = 1;i <= mxr;i++){
				for(int j = 1;j <= m;j++){
					eat[i][j] = 0;
				}
			}
			for(int i = 1;i <= n;i++){
				if(by == i) continue;
				for(int j = l[i];j <= r[i];j++){
					for(int kk = 1;kk <= k[i];kk++){
						eat[j][x[i][kk]] = 1;
					}
				}
			}
			printf("%lld ", getans());
		}//while(1);
		return 0;
	}
} int main(){
//	freopen("doctor.in", "r", stdin);
////	freopen("ex_doctor2.in", "r", stdin);
//	freopen("doctor.out", "w", stdout);
	return ac::main();
}//199MB

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7968kb

input:

5 4
1000 100 10 1
3 4 2 2 3
4 8 3 1 2 4
6 7 2 3 4
8 9 2 1 4
2 6 3 1 2 3

output:

8766 7564 8756 7765 6646 

result:

ok 5 number(s): "8766 7564 8756 7765 6646"

Test #2:

score: 0
Accepted
time: 1ms
memory: 7728kb

input:

1 1
1
1 1 1 1

output:

0 

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 1ms
memory: 7928kb

input:

1 2
10 1
1 2 1 2

output:

0 

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 1ms
memory: 9720kb

input:

2 1
1
1 2 1 1
3 4 1 1

output:

2 2 

result:

ok 2 number(s): "2 2"

Test #5:

score: 0
Accepted
time: 1ms
memory: 7980kb

input:

2 1
1
1 2 1 1
2 3 1 1

output:

2 2 

result:

ok 2 number(s): "2 2"

Test #6:

score: 0
Accepted
time: 1ms
memory: 7744kb

input:

1 3
1000000 909090 700700
1 1000000 3 1 2 3

output:

0 

result:

ok 1 number(s): "0"

Test #7:

score: -100
Runtime Error

input:

2 1
1000000
1 500000 1 1
500000 1000000 1 1

output:


result: