QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#30016#237. Triangle PartitionsrfRE 0ms0kbC++14871b2022-04-24 08:38:492022-04-28 12:19:04

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-28 12:19:04]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-04-24 08:38:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int T;

int n,ansbase;
struct data{
	int a,b;
	bool operator < (const data w) const{
		return a + max(0,w.a - b) < w.a + max(0,a - w.b);
	}
}a[100050];

void work(data &t){
	string s;
	cin >> s;
	t.a = t.b = 0;
	int l = 0;
	for (int i = 0; i < s.size(); ++i){
		if (s[i] == '(') ++l;
		else{
			if (l > 0) ansbase += 2,--l;
			else ++t.a;
		}
	}
	t.b = l;
}

void solve(){
	ansbase = 0;
	int suma = 0,sumb = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) work(a[i]),suma += a[i].a,sumb += a[i].b;
	sort(a + 1,a + n + 1);
	int now = 0,premax = 0;
	for (int i = 1; i <= n; ++i){
		now += a[i].a,premax = max(premax,a[i].a);
		now -= a[i].b;
	}
	ansbase += 2*(suma-premax);
	cout<<ansbase<<'\n';
}

int main(){
	ios::sync_with_stdio(0);
	cin >> T;
	while (T--) solve();
	return 0;
} 

詳細信息

Test #1:

score: 0
Runtime Error

input:

190
10
-7215 2904
-5179 1663
-542 1091
-5687 7868
7838 -1048
-2944 4346
-2780 3959
-9402 1099
-8548 -7238
-3821 -2917
2713 295
-856 -8661
7651 3945
-8216 -543
5798 5024
8583 -3384
-1208 5955
3068 -385
340 2968
6559 -272
4537 5075
5126 4343
639 8281
1700 2572
819 9317
-9854 -1316
-3421 -1137
9368 718...

output:

78

result: