Submission #00066


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
#define endl "\n"
#define INF INT_MAX
using namespace std;
int main(){
#define int long long
cin.tie(nullptr);ios::sync_with_stdio(false);
int n,m;
cin >>n>>m;
vector<vector<bool>>a(n,vector<bool>(m));
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
int x;
cin >>x;
a[i][j] = x;
}
}
int s = 0;
for(int bit = 0;bit < (1<<n);bit++){
int ans = 0;
for(int j = 0;j < m;j++){
int x = 0;
for(int k = 0;k < n;k++){
if(bit & (1<<k)){
if(a[k][j] == 0){
x++;
}
}else{
if(a[k][j] == 1)x++;
}
}
ans += max(x,n-x);
}
s = max(s,ans);
}
cout <<s<<endl;
}

ステータス

項目 データ
問題 0007 - おせんべい
ユーザー名 ei2332
投稿日時 2023-11-13 15:51:11
言語 C++17
状態 Accepted
得点 100
ソースコード長 787 Byte
最大実行時間 139 ms
最大メモリ使用量 512 KB

セット

セット 得点 Cases
1 ALL 100 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2008-yo-t5-in1.txt AC 36 ms 476 KB
1
2008-yo-t5-in2.txt AC 17 ms 428 KB
1
2008-yo-t5-in3.txt AC 21 ms 512 KB
1
2008-yo-t5-in4.txt AC 84 ms 460 KB
1
2008-yo-t5-in5.txt AC 139 ms 404 KB
1