Submission #00096
ソースコード
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> #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 h,w; cin >>h>>w; vector<string>s(h); for ( int i = 0;i < h;i++)cin >>s[i]; vector<vector< int >>sum(3,vector< int >(h)); for ( int i = 0;i < h;i++){ for ( int j = 0;j < w;j++){ if (s[i][j] == 'R' )sum[2][i]++; if (s[i][j] == 'W' )sum[0][i]++; if (s[i][j] == 'B' )sum[1][i]++; } } int Min = INF; for ( int i = 1;i < h-1;i++){ //白と青の境界 for ( int j = i+1;j < h;j++){ //青と赤の境界 int ans = 0; for ( int l = 0;l < i;l++)ans += w-sum[0][l]; for ( int l = i;l < j;l++)ans += w-sum[1][l]; for ( int l = j;l < h;l++)ans += w-sum[2][l]; //cout <<i<<" "<<j<<" "<<ans<<endl; Min = min(Min,ans); } } cout <<Min<<endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0001 - ロシアの旗 (Russian Flag) |
ユーザー名 | ei2332 |
投稿日時 | 2023-11-13 17:58:55 |
言語 | C++17 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 882 Byte |
最大実行時間 | 23 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 | 20 ms | 604 KB |
1
|
||||
2016-yo-t3-in2.txt | AC | 23 ms | 560 KB |
2
|
||||
2016-yo-t3-in3.txt | AC | 21 ms | 636 KB |
3
|
||||
2016-yo-t3-in4.txt | AC | 22 ms | 708 KB |
4
|
||||
2016-yo-t3-in5.txt | AC | 16 ms | 652 KB |
5
|
||||
2016-yo-t3-in_s1.txt | AC | 23 ms | 596 KB | |||||
2016-yo-t3-in_s2.txt | AC | 19 ms | 552 KB |