제출 #889721

#제출 시각아이디문제언어결과실행 시간메모리
889721vjudge1Council (JOI23_council)C++17
22 / 100
224 ms24324 KiB
#include <bits/stdc++.h>
using namespace std;/*
<<<<It's never too late for a new beginning in your life>>>>
Today is hard
  tomorrow will worse
  but the day after tomorrow will be the sunshine..
 
HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD............
Never give up  */
//The most CHALISHKANCHIK
#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
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vii;
const int N = 2e5+50, inf = 1e18, mod = 1e9+7;
void solve(){
	int n, m;
	cin >> n >> m;
	int a[n][m];
	int sum[m]{}, rez[m]{};
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
			rez[j]+=a[i][j];
		}
	}
	//~ for(auto i:rez)cout << i << ' ';
	//~ cout << '\n';
	int ans, cnt;
	if(n <= 9000){
		for(int i = 0; i < n; i++){
			ans = 0;
			for(int j = 0; j < n; j++){
				if(j == i)continue;
				cnt = 0;
				for(int k = 0; k < m; k++){
					sum[k] = rez[k];
					sum[k] -= a[i][k];
					sum[k] -= a[j][k];
					if(sum[k] >= n/2)cnt++;
				}
				//~ cout << '\n';
				ans = max(cnt, ans);
			}
			cout << ans << '\n';
		}
	}
	else{
		int sum = 0, it = 0;
		int sum2 = 0, it2 = 0;
		for(int i = 0; i < n; i++){
			int res = 0;
			for(int j = 0; j < m; j++){
				res+=(rez[j] - a[i][j] >= n/2);
			}
			if(res >= sum){
				sum2 = sum;it2 = it;
				sum = res;it = i;
			}
		}
		for(int i = 0; i < n; i++){
			int cnt = 0;
			if(i != it){
				for(int j = 0; j < m; j++){
					cnt += (rez[j] - (a[i][j]+a[it][j]) >= n/2);
				}
			}else{
				for(int j = 0; j < m; j++){
					cnt += (rez[j] - (a[i][j]+a[it2][j]) >= n/2);
				}
			}
			cout << cnt << '\n';
		}
	}
}
main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	//~ cin >> t;
	while(t--){
		solve();
	}
}

컴파일 시 표준 에러 (stderr) 메시지

council.cpp: In function 'void solve()':
council.cpp:55:7: warning: variable 'sum2' set but not used [-Wunused-but-set-variable]
   55 |   int sum2 = 0, it2 = 0;
      |       ^~~~
council.cpp: At global scope:
council.cpp:81:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   81 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...