2535 Very Simple Problem

「2535 Very Simple Problem」の編集履歴(バックアップ)一覧に戻る

2535 Very Simple Problem - (2006/04/17 (月) 02:21:04) のソース

**2535 Very Simple Problem
**問題
http://acm.pku.edu.cn/JudgeOnline/problem?id=2535
**解答例
 import java.util.*;
 public class Main {
     public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         int n = sc.nextInt();
         int p = sc.nextInt();
         int[] simplest = new int[p];
         Arrays.fill(simplest,0);
         boolean[] hardest = new boolean[p];
         Arrays.fill(hardest,false);
         for(int i=0;i<n;i++){
             int[] rating = new int[p];
             int min = 1001;
             int max = -1;
             for(int j=0;j<p;j++){
                 rating[j] = sc.nextInt();
                 if(min>rating[j]) min = rating[j];
                 if(max<rating[j]) max = rating[j];
             }
             for(int j=0;j<p;j++){
                 if(min==rating[j]) simplest[j]++;
                 if(max==rating[j]) hardest[j] = true;
             }
         }
         boolean noverysimple = true;
         for(int i=0;i<p;i++){
             if(simplest[i]*2>n&&!hardest[i]){
                 System.out.print((i+1)+" ");
                 noverysimple = false;
             }
         }
         if(noverysimple) System.out.println(0);
         else System.out.println();
     }
 }
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。