답안 #587529

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587529 2022-07-02T04:51:16 Z Tekor Team Contest (JOI22_team) C++17
37 / 100
2000 ms 5168 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
void boos() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int N = 3e5 + 100;
const ll LLINF = (ll)1e18;
ll a[N],b[N],c[N];
int n;
bool cmp(int x,int y) {
	return a[x] < a[y];
}
bool cmp1(int x,int y) {
	return b[x] < b[y];
}
void solve() {
	cin >> n;
	vector <int> g,q;
	for(int i = 1;i <= n;i++) {
		cin >> a[i] >> b[i] >> c[i];
		g.pb(i);
		q.pb(i);
	}
	sort(all(g),cmp);
	sort(all(q),cmp1);
	ll ans = -1;
	for(auto v : g) {
		ll mxa = a[v];
		set <ll> tt;
		//cout << v << " -- " << a[v] << endl;
		for(int j = 0;j < q.size();j++) {
			int to = q[j];
			ll mxb = b[to];
			//cout << to << " :: " << b[to] << " == ";
			if(j > 0 && b[q[j - 1]] != b[to]) {
				int pos = j - 1;
				while(pos >= 0 && b[q[pos]] == b[q[j - 1]]) {
					int p = q[pos];
					if(a[p] < mxa)tt.insert(c[p]);
					pos--;
				}	
			}
			if(a[to] >= mxa || b[v] >= mxb) {
				//cout << "fail" << endl;
				continue;
			}
			if(!tt.empty()) {
				ll val = *(tt.rbegin());
				if(val > max(c[v],c[to]))ans = max(ans,mxa + mxb + val);
				//cout << val << " ";
			}
			//cout << ans << endl;
		}
		//cout << ans << endl;
	} 
	cout << ans;
}
int main() {
	boos();
	solve();
}

Compilation message

team.cpp: In function 'void solve()':
team.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for(int j = 0;j < q.size();j++) {
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 4 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 368 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 4 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 368 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 1020 ms 692 KB Output is correct
27 Correct 979 ms 884 KB Output is correct
28 Correct 922 ms 892 KB Output is correct
29 Correct 778 ms 596 KB Output is correct
30 Correct 382 ms 608 KB Output is correct
31 Correct 695 ms 672 KB Output is correct
32 Correct 429 ms 528 KB Output is correct
33 Correct 73 ms 572 KB Output is correct
34 Correct 780 ms 792 KB Output is correct
35 Correct 21 ms 404 KB Output is correct
36 Correct 20 ms 344 KB Output is correct
37 Correct 600 ms 576 KB Output is correct
38 Correct 545 ms 576 KB Output is correct
39 Correct 59 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Execution timed out 2085 ms 5168 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Execution timed out 2085 ms 5168 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Execution timed out 2085 ms 5168 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Execution timed out 2085 ms 5168 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 4 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 368 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 1020 ms 692 KB Output is correct
27 Correct 979 ms 884 KB Output is correct
28 Correct 922 ms 892 KB Output is correct
29 Correct 778 ms 596 KB Output is correct
30 Correct 382 ms 608 KB Output is correct
31 Correct 695 ms 672 KB Output is correct
32 Correct 429 ms 528 KB Output is correct
33 Correct 73 ms 572 KB Output is correct
34 Correct 780 ms 792 KB Output is correct
35 Correct 21 ms 404 KB Output is correct
36 Correct 20 ms 344 KB Output is correct
37 Correct 600 ms 576 KB Output is correct
38 Correct 545 ms 576 KB Output is correct
39 Correct 59 ms 340 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Execution timed out 2085 ms 5168 KB Time limit exceeded
51 Halted 0 ms 0 KB -