Older Research Bldg. No.7
問題概要
解法
入力の年数がQを超えたらその前の名前が答えになる
コード
(2544.cpp) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| #include <iostream>
#include <string>
#define rep(i,a) for(int i = 0;i < (a); i++)
using namespace std;
int main(){
int n, q;
cin >> n >> q;
string ans = "kogakubu10gokan";
bool ok = false;
while(n--){
int y;
string str;
cin >> y >> str;
if(!ok && y > q){
ok = true;
}
if(!ok)ans = str;
}
cout << ans << endl;
}
|