답안 #587558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587558 2022-07-02T05:25:53 Z Red_Inside Team Contest (JOI22_team) C++17
36 / 100
946 ms 7248 KB
//
#include <bits/stdc++.h>

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long

using namespace std;
const int maxn=3e5+10,LOG=17, mod=1e9+7;
int block = 320, timer = 0;
const ld EPS = 1e-18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define bt(i) (1 << (i))
#define int ll
const int inf=2e18;
#define y1 yy
#define prev pre
#define pii pair <int, int>

int n, a[maxn], b[maxn], c[maxn], ind[maxn], pref[maxn], mnc[maxn];

bool cmp(int i, int j)
{
	if(a[i] == a[j])
	{
		if(b[i] == b[j]) return c[i] < c[j];
		else return b[i] < b[j];
	}
	else return a[i] < a[j];
}

void add(int i)
{
	int A = a[i];
	int B = b[i];
	int C = c[i];
	forn(B, i, 4000)
	{
		pref[i] = max(pref[i], C);
	}
	mnc[B] = min(mnc[B], C);
}

int check(int A, int B, int C)
{
	int ret = -inf;
	forn(B + 1, i, 4000)
	{
		if(pref[i - 1] > max(C, mnc[i]))
		{
			ret = max(ret, pref[i - 1] + A + i);
		}
	}
	return ret;
}

main()
{
	IOS
	cin >> n;
	forn(1, i, n)
	{
		cin >> a[i] >> b[i] >> c[i];
		ind[i] = i;
	}
	forn(1, i, 4000) mnc[i] = inf;
	forn(1, i, 4000) pref[i] = -inf;
	sort(ind + 1, ind + 1 + n, cmp);
	int ans = -inf;
	forn(1, i, n)
	{
		int j = i;
		while(a[ind[j+1]] == a[ind[i]])
		{
			ans = max(ans, check(a[ind[j]], b[ind[j]], c[ind[j]]));
			++j;
		}
		ans = max(ans, check(a[ind[j]], b[ind[j]], c[ind[j]]));
		forn(i, k, j)
		{
			add(ind[k]);
		}
		i = j;
	}
	if(ans < 0) cout << -1;
	else
		cout << ans;
}

Compilation message

team.cpp: In function 'void add(long long int)':
team.cpp:46:6: warning: unused variable 'A' [-Wunused-variable]
   46 |  int A = a[i];
      |      ^
team.cpp: At global scope:
team.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 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 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Runtime error 1 ms 596 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 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 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Runtime error 1 ms 596 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 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 924 ms 5120 KB Output is correct
12 Correct 623 ms 3716 KB Output is correct
13 Correct 751 ms 4404 KB Output is correct
14 Correct 912 ms 5236 KB Output is correct
15 Correct 897 ms 5232 KB Output is correct
16 Correct 889 ms 5232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 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 924 ms 5120 KB Output is correct
12 Correct 623 ms 3716 KB Output is correct
13 Correct 751 ms 4404 KB Output is correct
14 Correct 912 ms 5236 KB Output is correct
15 Correct 897 ms 5232 KB Output is correct
16 Correct 889 ms 5232 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 12 ms 468 KB Output is correct
22 Correct 925 ms 5228 KB Output is correct
23 Correct 920 ms 4992 KB Output is correct
24 Correct 671 ms 3936 KB Output is correct
25 Correct 946 ms 5092 KB Output is correct
26 Correct 905 ms 5204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 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 924 ms 5120 KB Output is correct
12 Correct 623 ms 3716 KB Output is correct
13 Correct 751 ms 4404 KB Output is correct
14 Correct 912 ms 5236 KB Output is correct
15 Correct 897 ms 5232 KB Output is correct
16 Correct 889 ms 5232 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 12 ms 468 KB Output is correct
22 Correct 925 ms 5228 KB Output is correct
23 Correct 920 ms 4992 KB Output is correct
24 Correct 671 ms 3936 KB Output is correct
25 Correct 946 ms 5092 KB Output is correct
26 Correct 905 ms 5204 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 4 ms 436 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 25 ms 468 KB Output is correct
32 Correct 6 ms 456 KB Output is correct
33 Correct 6 ms 468 KB Output is correct
34 Correct 870 ms 5120 KB Output is correct
35 Correct 807 ms 4912 KB Output is correct
36 Correct 938 ms 5104 KB Output is correct
37 Correct 893 ms 5312 KB Output is correct
38 Correct 850 ms 5244 KB Output is correct
39 Correct 550 ms 3480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 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 924 ms 5120 KB Output is correct
12 Correct 623 ms 3716 KB Output is correct
13 Correct 751 ms 4404 KB Output is correct
14 Correct 912 ms 5236 KB Output is correct
15 Correct 897 ms 5232 KB Output is correct
16 Correct 889 ms 5232 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 12 ms 468 KB Output is correct
22 Correct 925 ms 5228 KB Output is correct
23 Correct 920 ms 4992 KB Output is correct
24 Correct 671 ms 3936 KB Output is correct
25 Correct 946 ms 5092 KB Output is correct
26 Correct 905 ms 5204 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 4 ms 436 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 25 ms 468 KB Output is correct
32 Correct 6 ms 456 KB Output is correct
33 Correct 6 ms 468 KB Output is correct
34 Correct 870 ms 5120 KB Output is correct
35 Correct 807 ms 4912 KB Output is correct
36 Correct 938 ms 5104 KB Output is correct
37 Correct 893 ms 5312 KB Output is correct
38 Correct 850 ms 5244 KB Output is correct
39 Correct 550 ms 3480 KB Output is correct
40 Correct 12 ms 548 KB Output is correct
41 Correct 24 ms 596 KB Output is correct
42 Correct 21 ms 596 KB Output is correct
43 Correct 21 ms 596 KB Output is correct
44 Correct 693 ms 5396 KB Output is correct
45 Correct 462 ms 7216 KB Output is correct
46 Correct 574 ms 7240 KB Output is correct
47 Correct 387 ms 7248 KB Output is correct
48 Correct 269 ms 7116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 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 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Runtime error 1 ms 596 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -