# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1089181 |
2024-09-16T06:58:32 Z |
em4ma2 |
Izbori (COCI17_izbori) |
C++14 |
|
28 ms |
476 KB |
// بسم الله الرحمن الرحيم
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define int long long
#define pb push_back
#define endl '\n'
#define ld long double
#define applejuice ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const ll mod=1e9+7;
const ll inf=1e18;
const ll mxsz=100+4;
const ld pi=acos(-1.0);
int win[mxsz];//m
vector<int>need;
int a[mxsz][19];
signed main() {
applejuice;
int n,m,k;
cin>>n>>m>>k;
for (int i=0;i<n;i++){
for (int j=0;j<m;j++){
cin>>a[i][j];
if(j==0)win[a[i][0]]++;
}
}
/*for(int i=0;i<need.size();i++){
cout<<need[i]<<" ";
}cout<<endl;*/
/*for (int i=0;i<=m;i++){
cout<<win[i]<<" ";
}cout<<endl;*/
int mxn=-1,mxi=0;
for (int i=0;i<=m;i++){
if (win[i]>mxn){
mxn=win[i];
mxi=i;
}
}
//cout<<mxi<<" "<<mxn<<endl;
cout<<mxi<<endl;
//everything good so far
int ans=m;
for (int ma=1;ma<(1<<m);ma++){
bool rev[m+1]={};
int cnt=0;
for (int i=0;i<m;i++){
if((1<<i)&ma){
rev[i+1]=1;
}else{
cnt++;
}
}
/*for (int i=0;i<=m;i++){
cout<<rev[i]<<" ";
}
cout<<endl;*/
int cur=m,mx=-1;
vector<int>t;
for (int i=0;i<n;i++){
for (int j=0;j<m;j++){
if(rev[a[i][j]]){
t.pb(a[i][j]);
break;
}
}
}
int wn[m+1]={};
for (auto x:t)wn[x]++;
for (int i=0;i<=m;i++){
mx=max(mx,wn[i]);
}
for (int i=0;i<=m;i++){
if(wn[i]==mx){
cur=i;
break;
}
}
if(cur==k){
ans=min(cnt,ans);
//cout<<"jlefi"<<endl;
}
}
cout<<ans<<endl;
/*if(mxi==k){
cout<<0;
return 0;
}
int ans=0,ned;
if (mxi<k){
ned=(mxn+1)/2;
//cout<<ned<<endl;
sort(need.begin(),need.end());
//cout<<need[0]<<endl;
for (int i=0;i<ned;i++){
ans+=need[i];
}
}else{
ned=mxn/2;
//cout<<ned<<endl;
sort(need.begin(),need.end());
for (int i=0;i<ned;i++){
ans+=need[i];
}
}
cout<<ans<<endl;*/
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
6 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
6 ms |
344 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
344 KB |
Output is correct |
12 |
Correct |
13 ms |
348 KB |
Output is correct |
13 |
Correct |
24 ms |
476 KB |
Output is correct |
14 |
Correct |
13 ms |
344 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
27 ms |
344 KB |
Output is correct |
17 |
Correct |
13 ms |
344 KB |
Output is correct |
18 |
Correct |
28 ms |
348 KB |
Output is correct |
19 |
Correct |
26 ms |
344 KB |
Output is correct |
20 |
Correct |
26 ms |
348 KB |
Output is correct |