Submission #1094569

#TimeUsernameProblemLanguageResultExecution timeMemory
1094569IzzyAdvertisement 2 (JOI23_ho_t2)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <queue> using namespace std; //https://pastebin.com/LckN30bC // keep values of x + e, x - e; sort by left and then right int n; bool compare(static pair<int, int> a, static pair<int, int> b) { if (a.first != b.first) { return a.first < b.first; } return a.second > b.second; // 1 4, 1 3, 1 2 } int main() { cin >> n; vector<pair<int, int>> range(n); int x, e; for (int i = 0; i < n; i++) { cin >> x >> e; range[i].first = x - e; range[i].second = x + e; } sort(range.begin(), range.end(), compare); int maximum = -1; int answer = 0; for (int i = 0; i < n; i++) { if (maximum < range[i].second) { answer++; maximum = range[i].second; } } cout << answer; }

Compilation message (stderr)

Main.cpp:10:14: error: storage class specified for parameter 'a'
   10 | bool compare(static pair<int, int> a, static pair<int, int> b) {
      |              ^~~~~~
Main.cpp:10:37: error: expected ')' before ',' token
   10 | bool compare(static pair<int, int> a, static pair<int, int> b) {
      |             ~                       ^
      |                                     )
Main.cpp:10:39: error: expected unqualified-id before 'static'
   10 | bool compare(static pair<int, int> a, static pair<int, int> b) {
      |                                       ^~~~~~
Main.cpp: In function 'int main()':
Main.cpp:26:5: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   26 |     sort(range.begin(), range.end(), compare);
      |     ^~~~
      |     qsort