답안 #892165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892165 2023-12-25T02:46:38 Z vjudge1 Team Contest (JOI22_team) C++17
8 / 100
2000 ms 6744 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
#define rnd(l, r) uniform_int_distribution<int>(l, r)(rng)
 
using namespace std;

void fp(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} 
int pow(int a,int b,int m){int ans=1;while(b){if(b&1){ans=(ans*a)%m;}b>>=1;a=(a*a)%m;}return ans;}
int binpow(int a,int b){int ans=1;while(b){if(b&1){ans=(ans*a);}b>>=1;a=(a*a);}return ans;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int N = 200005, maxn =200005, inf = 2e9;

int a[5][N];

main(){
	iostream::sync_with_stdio(false);	
    cin.tie(nullptr);
    cout.tie(nullptr);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= 3; j++){
			cin >> a[j][i];
		}
	}
	int ans = -1;
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j  <= n; j++){
			for(int l = j + 1; l <= n; l++){
				vector <int8_t> flag(3);
				int sum = 0;
				
				for(int pe = 1; pe <= 3; pe++){
					vector < pair <int,int> > f;
					f.pb({a[pe][i], 0});
					f.pb({a[pe][j], 1});
					f.pb({a[pe][l], 2});
					sort(rall(f));
					sum += f[0].ff;
					flag[f[0].ss] = 1;
					if(f[0].ff == f[1].ff){
						flag[1] = 0;
						break;
					}
				}
				if(*min_element(all(flag)) == 1)
					ans = max(sum, ans);
			}
		}
	}
	cout << ans << endl;
}
/*
 * Before implementing the problem:
	
	Do I understand the problem correctly?
	Which places are tricky? What do I need to remember to implement them correctly?
	Which place is the heaviest by implementation? Can I do it simpler?
	Which place is the slowest? Where do I need to be careful about constant factors and where I can choose slower but simpler implementation?
	----------------------------------
	If not AC:
 
	Did you remember to do everything to handle the tricky places you thought about before?
	Is the solution correct?
	Do I understand the problem correctly?
	----------------------------------
	If you have a test on which the solution gives wrong answer:
 
	Is the solution doing what it was supposed to do?
	Is the problem in the code or in the idea?
*/

Compilation message

team.cpp:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   24 | main(){
      | ^~~~
team.cpp: In function 'void fp(std::string)':
team.cpp:15:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 | void fp(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:15:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 | void fp(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6744 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1039 ms 6604 KB Output is correct
15 Correct 507 ms 6604 KB Output is correct
16 Correct 747 ms 6600 KB Output is correct
17 Correct 1004 ms 6608 KB Output is correct
18 Correct 849 ms 6624 KB Output is correct
19 Correct 1028 ms 6600 KB Output is correct
20 Correct 865 ms 6600 KB Output is correct
21 Correct 406 ms 6604 KB Output is correct
22 Correct 836 ms 6600 KB Output is correct
23 Correct 337 ms 6604 KB Output is correct
24 Correct 914 ms 6608 KB Output is correct
25 Correct 917 ms 6600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6744 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1039 ms 6604 KB Output is correct
15 Correct 507 ms 6604 KB Output is correct
16 Correct 747 ms 6600 KB Output is correct
17 Correct 1004 ms 6608 KB Output is correct
18 Correct 849 ms 6624 KB Output is correct
19 Correct 1028 ms 6600 KB Output is correct
20 Correct 865 ms 6600 KB Output is correct
21 Correct 406 ms 6604 KB Output is correct
22 Correct 836 ms 6600 KB Output is correct
23 Correct 337 ms 6604 KB Output is correct
24 Correct 914 ms 6608 KB Output is correct
25 Correct 917 ms 6600 KB Output is correct
26 Execution timed out 2015 ms 6488 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6744 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Execution timed out 2050 ms 6492 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6744 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Execution timed out 2050 ms 6492 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6744 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Execution timed out 2050 ms 6492 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6744 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Execution timed out 2050 ms 6492 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6744 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1039 ms 6604 KB Output is correct
15 Correct 507 ms 6604 KB Output is correct
16 Correct 747 ms 6600 KB Output is correct
17 Correct 1004 ms 6608 KB Output is correct
18 Correct 849 ms 6624 KB Output is correct
19 Correct 1028 ms 6600 KB Output is correct
20 Correct 865 ms 6600 KB Output is correct
21 Correct 406 ms 6604 KB Output is correct
22 Correct 836 ms 6600 KB Output is correct
23 Correct 337 ms 6604 KB Output is correct
24 Correct 914 ms 6608 KB Output is correct
25 Correct 917 ms 6600 KB Output is correct
26 Execution timed out 2015 ms 6488 KB Time limit exceeded
27 Halted 0 ms 0 KB -