CSES - Aalto Competitive Programming 2024 - wk2 - Wed - Results
Submission details
Task:Binge watching
Sender:aalto2024b_007
Submission time:2024-09-11 16:25:51 +0300
Language:C++11
Status:COMPILE ERROR

Compiler report

input/code.cpp:5:20: warning: missing terminating ' character
    5 | pair<int,int> A[200'001];
      |                    ^
input/code.cpp:5:20: error: missing terminating ' character
    5 | pair<int,int> A[200'001];
      |                    ^~~~~~
input/code.cpp:5:20: error: expected ']' before 'int'
    5 | pair<int,int> A[200'001];
      |                    ^
      |                    ]
    6 | int n;
      | ~~~                 
input/code.cpp: In function 'int main()':
input/code.cpp:9:16: error: 'n' was not declared in this scope; did you mean 'yn'?
    9 |         cin >> n;
      |                ^
      |                yn
input/code.cpp:13:17: error: 'A' was not declared in this scope
   13 |                 A[i] = {b,a};
      |                 ^
input/code.cpp:15:14: error: 'A' was not declared in this scope
   15 |         sort(A,A+n);
      |              ^

Code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

pair<int,int> A[200'001];
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		A[i] = {b,a};
	}
	sort(A,A+n);
	int ans = 0;
	int l = 0;
	for (int i = 0; i < n; ++i) {
		if (l <= A[i].second) {
			l = A[i].first;
			++ans;
		}
	}
	cout << ans;
}