Submission #701766

# Submission time Handle Problem Language Result Execution time Memory
701766 2023-02-22T05:11:01 Z lto5 Lightning Rod (NOI18_lightningrod) C++14
80 / 100
2000 ms 247220 KB
#include <bits/stdc++.h>

using namespace std;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#define task "a"
  if (fopen(task ".inp", "r")) {
    freopen(task ".inp", "r", stdin);
    freopen(task ".out", "w", stdout);
    // freopen(task ".txt", "w", stderr);
  }
  int n;
  cin >> n;
  vector<pair<int, int>> vt;
  stack<int> st;
  while (n--) {
    int x, y;
    cin >> x >> y;
    vt.emplace_back(x + y, y - x);
  }
  sort(vt.begin(), vt.end());
  for (auto [x, y] : vt) {
    while (!st.empty() && st.top() <= y) {
      st.pop();
    }
    st.push(y);
  }
  cout << st.size();
  return 0;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:33:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |   for (auto [x, y] : vt) {
      |             ^
lightningrod.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen(task ".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
lightningrod.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen(task ".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1596 ms 196828 KB Output is correct
2 Correct 1649 ms 196356 KB Output is correct
3 Correct 1583 ms 195172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 55 ms 5448 KB Output is correct
15 Correct 49 ms 5292 KB Output is correct
16 Correct 38 ms 4744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1635 ms 187336 KB Output is correct
2 Correct 1631 ms 185460 KB Output is correct
3 Correct 1580 ms 184028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1596 ms 196828 KB Output is correct
2 Correct 1649 ms 196356 KB Output is correct
3 Correct 1583 ms 195172 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 316 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 55 ms 5448 KB Output is correct
18 Correct 49 ms 5292 KB Output is correct
19 Correct 38 ms 4744 KB Output is correct
20 Correct 1635 ms 187336 KB Output is correct
21 Correct 1631 ms 185460 KB Output is correct
22 Correct 1580 ms 184028 KB Output is correct
23 Execution timed out 2076 ms 247220 KB Time limit exceeded
24 Halted 0 ms 0 KB -