Submission #00054


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
int main(){
int h,w;cin>>h>>w;
vector<int>w1(h,0),b1(h,0),r1(h,0);
string s[h];
for(int i=0;i<h;i++)cin>>s[i];
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(s[i][j]=='W')w1[i]++;
if(s[i][j]=='B')b1[i]++;
if(s[i][j]=='R')r1[i]++;
}
}
long long ans=h*w;
for(int i=1;i<h-1;i++){
for(int j=i;j<h-1;j++){
long long k=0;
for(int l=0;l<i;l++){
k+=w-w1[l];
}
for(int l=i;l<=j;l++){
k+=w-b1[l];
}
for(int l=j+1;l<h;l++){
k+=w-r1[l];
}
ans=min(ans,k);
}
}
cout<<ans<<"\n";
}

ステータス

項目 データ
問題 0001 - ロシアの旗 (Russian Flag)
ユーザー名 ei2326
投稿日時 2023-11-13 12:12:52
言語 C++17
状態 Accepted
得点 100
ソースコード長 793 Byte
最大実行時間 28 ms
最大メモリ使用量 708 KB

セット

セット 得点 Cases
1 INPUT1 20 / 20 *in1.txt
2 INPUT2 20 / 20 *in2.txt
3 INPUT3 20 / 20 *in3.txt
4 INPUT4 20 / 20 *in4.txt
5 INPUT5 20 / 20 *in5.txt

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2016-yo-t3-in1.txt AC 17 ms 604 KB
1
2016-yo-t3-in2.txt AC 24 ms 708 KB
2
2016-yo-t3-in3.txt AC 22 ms 552 KB
3
2016-yo-t3-in4.txt AC 18 ms 520 KB
4
2016-yo-t3-in5.txt AC 20 ms 488 KB
5
2016-yo-t3-in_s1.txt AC 28 ms 584 KB
2016-yo-t3-in_s2.txt AC 16 ms 560 KB