結果
| 問題 | 
                            No.509 塗りつぶしツール
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tenten
                         | 
                    
| 提出日時 | 2021-05-17 15:35:26 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 58 ms / 2,000 ms | 
| コード長 | 1,082 bytes | 
| コンパイル時間 | 2,680 ms | 
| コンパイル使用メモリ | 77,296 KB | 
| 実行使用メモリ | 50,416 KB | 
| 最終ジャッジ日時 | 2024-10-06 15:23:06 | 
| 合計ジャッジ時間 | 5,883 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 | 
ソースコード
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int[] holes = new int[]{1, 0, 0, 0, 1, 0, 1, 0, 2, 1};
        int line = 0;
        int inside = 0;
        for (char c : sc.next().toCharArray()) {
            line++;
            inside += holes[c - '0'];
        }
        int min = Math.min(line * 2 + inside + 1, (1 + inside) * 2 + line);
        System.out.println(min);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
            
            
            
        
            
tenten