2020年智算の道初戦第3戦-高校組Java題解
8164 ワード
A.コップ
http://oj.csen.org.cn/contest/9/26
タイトルの説明
ここでは小さなDDを引用して温度を表示できるコップがある.その原理はコップの蓋の上のセンサーである.コップ内の水の体積がある数LL以上の場合にのみセンサーが水温を表示することができ,また水温が[A,B]内になければセンサーも水温を表示することができない.ここで温度が水の体積に影響を与えないことに注意する.nn回の操作があり、操作は3種類に分けられます.1 xは水温をxxにすることを示す. .2 xは水の体積をxxにすることを示す. .3センサの表示状況を調べる.水温出力GGを表示できない場合は水温を出力する. .
入力フォーマット
第1行の4つの整数n,L,A,Bn,L,A,B、意味はタイトルの通りである.次にnn行は、各行に1つの整数optoptまたは2つの整数opt,xopt,x、実行操作optoptを表す.
出力フォーマット
全ての操作3の出力結果について、1行につき1つの答えが出力.
データ規模と約定
100%のデータに対して、1≦n≦1000、-273≦A≦B≦100、1≦L≦1000、1≦opt≦3.操作1に対して、-273≦x≦100;操作2については、1≦x≦1000である.
サンプル入力
5 2 1 3 1 5 2 3 3 1 2 3
サンプル出力
GG 2
データについては、直接問題に従ってシミュレーションすればいいです.次はACコードです.
http://oj.csen.org.cn/contest/9/26
タイトルの説明
ここでは小さなDDを引用して温度を表示できるコップがある.その原理はコップの蓋の上のセンサーである.コップ内の水の体積がある数LL以上の場合にのみセンサーが水温を表示することができ,また水温が[A,B]内になければセンサーも水温を表示することができない.ここで温度が水の体積に影響を与えないことに注意する.nn回の操作があり、操作は3種類に分けられます.
入力フォーマット
第1行の4つの整数n,L,A,Bn,L,A,B、意味はタイトルの通りである.次にnn行は、各行に1つの整数optoptまたは2つの整数opt,xopt,x、実行操作optoptを表す.
出力フォーマット
全ての操作3の出力結果について、1行につき1つの答えが出力.
データ規模と約定
100%のデータに対して、1≦n≦1000、-273≦A≦B≦100、1≦L≦1000、1≦opt≦3.操作1に対して、-273≦x≦100;操作2については、1≦x≦1000である.
サンプル入力
5 2 1 3 1 5 2 3 3 1 2 3
サンプル出力
GG 2
データについては、直接問題に従ってシミュレーションすればいいです.次はACコードです.
import java.util.ArrayList;
import java.util.Scanner;
public class cup {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int L = in.nextInt();
int A = in.nextInt();
int B = in.nextInt();
ArrayList<String> ans = new ArrayList<String>();
int temp = 0;
int vector = 0;
for (int i = 0; i < n; i++) {
int n1 = in.nextInt();
if (n1 == 1) {
temp = in.nextInt();
continue;
}
if (n1 == 2) {
vector = in.nextInt();
continue;
}
if (n1 == 3) {
if (vector > L && temp >= A && temp <= B) {
ans.add(String.valueOf(temp));
} else {
ans.add("GG");
}
continue;
}
}
for (String x : ans) {
System.out.println(x);
}
}
}