Official
A - Streamer Takahashi Editorial by en_translator
For beginners
- If you are new to learning programming and do not know where to start, please try Problem A "Welcome to AtCoder" from practice contest. There you can find a sample code for each language.
- Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in "AtCoder Beginners Selection".
- 「C++入門 AtCoder Programming Guide for beginners (APG4b)」 is a C++ tutorial for competitive programmers. Sadly, this is only in Japanese too.
- 「Python入門 AtCoder Programming Guide for beginners (APG4bPython)」 is a Python tutorial for competitive programmers. Again, this is only in Japanese.
Person \(i\) can watch Takahashi’s stream for beginning to end only if the following two conditions are met:
- Person \(i\) can start watching on or before \(L\) o’clock.
- Person \(i\) can finish watching on or after \(R\) o’clock.
These can be expressed mathematically as \(X_i\leq L\) and \(R\leq Y_i\). All that left is to count the number of indices \(i\) satisfying them.
Sample code (Python)
N, L, R = map(int, input().split())
ans = 0
for i in range(N):
x, y = map(int, input().split())
if x <= L and R <= y:
ans += 1
print(ans)
Sample code(c++)
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, L, R, ans = 0;
cin >> N >> L >> R;
for (int i = 0; i < N; i++) {
int X, Y;
cin >> X >> Y;
if (X <= L && R <= Y) ans++;
}
cout << ans << endl;
}
posted:
last update: