AcWing 3267. 小明上学[Java]
原题链接
简单
作者:
情意
,
2021-03-19 10:15:42
,
所有人可见
,
阅读 296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String [] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] split = br.readLine().split(" ");
int r = Integer.parseInt(split[0]);
int n = Integer.parseInt(br.readLine());
int res = 0;
for(int i = 0 ;i < n ;i++){
String[] split1 = br.readLine().split(" ");
int a = Integer.parseInt(split1[0]);
int b = Integer.parseInt(split1[1]);
if (a==0 || a==1){
res+=b;
}else if (a==2){
res+=b + r;
}
}
System.out.println(res);
}
}