0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Java】AtCoderのABC-190に参加しました。

Last updated at Posted at 2021-01-30

こんばんは。

2021/1/30に、AtCoderのABC-190に参加しました。
レートは以下の通りとなっています。

image.png

今週もC問題が解けませんでした。
ぐやじいい・・。
レートは51→71に更新!ですが、今は参加回数が少なく本来のレートに近づいているだけのようです。そのうち横ばいになるんですね。
A問題でちょっと苦戦しまして、10分程度。今回はB問題の方が簡単だった気がします。

A問題

高橋くんがA個、青木くんがB個のアメを持っていて、Cが0であれば高橋くんが先攻、1なら青木君が先攻。
1個ずつアメを交互に食べて、先になくなった方が負け。
「先攻の個数>=後攻の個数+1だったら先攻の勝ち」という法則を見つけてコーディングしました。
不等号の付け方でちょっとね・・。
あと、Cをint型で定義したのに、C=='0'といったchar型の判定をしていたことに気付くのに3分ほどかかりました。
コンパイルエラーもないし、一定正解になってしまうので、「あれ?」となりまして・・。

import java.util.Scanner;
import java.util.ArrayList;

public class Main{
public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  if(c==0){
    if(a>=b+1){
    //System.out.println("t" + a + " " + b+1);
    System.out.println("Takahashi");
    }else{
    //System.out.println("A");
    System.out.println("Aoki");
    }
  }else{
    if(b>=a+1){
        System.out.println("Aoki");
    }else{
        System.out.println("Takahashi");
    }
  }

}
}

B問題

N 種類の呪文を使うことができる。
i 番目の呪文はX秒,威力はY。
呪文にS秒以上かかるもの、威力がD以下のものでは倒せない。

こちらの方がスッと入ってきまして、すぐ解けました。

import java.util.Scanner;
import java.util.ArrayList;

public class Main{
public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int s = sc.nextInt();
  int d = sc.nextInt();
  int x[] = new int[n];
  int y[] = new int[n];
  char ok = '0';
  for(int i=0;i<n;i++){
    x[i] = sc.nextInt();
    y[i] = sc.nextInt();
    if((x[i]<s)&&(y[i]>d)){
      ok='1';
      i=n;
    }
  }

if(ok=='1'){
System.out.println("Yes");
}else{
System.out.println("No");
}

  
}
}

C問題

*不正解のためソースは割愛します。
「どちらかを選択できる」という条件を、どうロジックに落とすか苦慮しました。

感想

C問題が自分には大きな壁なので練習します。
今回は家の用事で中断がありましたが、B問題まで15分~20分で解けるので多少の中断は何とかなりそうなので毎週参加できます。
今の実力から「あと3回でレート150」を目標にしてみることにしました。

これからもコツコツ取り組んで、茶色を目指したいと思います!
同じく灰色レベルで頑張っている方、お互い頑張りましょう!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?