Submission #824328

# Submission time Handle Problem Language Result Execution time Memory
824328 2023-08-14T02:40:42 Z christinelynn Lightning Rod (NOI18_lightningrod) C++17
100 / 100
659 ms 246460 KB
#include<bits/stdc++.h>
using namespace std;
const int INF=1e18;
int n, ans;
void read(int &in) {
  in=0;
  for(char c=getchar(); '0'<=c && c<='9'; c=getchar()) in=10*in+c-'0'; 
}
void post(int out) {
  char dig[11];
  int idx=0;
  do{
    dig[idx++]='0'+out%10;
    out/=10;
  } while(out);
  idx--;
  while(idx>=0) putchar(dig[idx--]);
}
int main() {
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n, x, y, ans=0; read(n);
  pair<int, int> a[n];
  int temp=-INF;
  for(int i=0; i<n; i++) {
    read(x); read(y);
    a[i].second=x-y;
    if(x+y<=temp) a[i].first=0;
    else a[i].first=1;
    temp=max(temp, x+y);
  } temp=INF;
  for(int i=n-1; i>=0; i--) {
    if(a[i].second<temp) ans+=a[i].first;
    temp=min(temp, a[i].second);
  }
  post(ans); putchar('\n');
  return 0;
}

Compilation message

lightningrod.cpp:3:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    3 | const int INF=1e18;
      |               ^~~~
# Verdict Execution time Memory Grader output
1 Correct 418 ms 189120 KB Output is correct
2 Correct 419 ms 188296 KB Output is correct
3 Correct 402 ms 183308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 13 ms 5332 KB Output is correct
15 Correct 13 ms 5156 KB Output is correct
16 Correct 13 ms 4464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 413 ms 174672 KB Output is correct
2 Correct 403 ms 174480 KB Output is correct
3 Correct 398 ms 170212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 418 ms 189120 KB Output is correct
2 Correct 419 ms 188296 KB Output is correct
3 Correct 402 ms 183308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 13 ms 5332 KB Output is correct
18 Correct 13 ms 5156 KB Output is correct
19 Correct 13 ms 4464 KB Output is correct
20 Correct 413 ms 174672 KB Output is correct
21 Correct 403 ms 174480 KB Output is correct
22 Correct 398 ms 170212 KB Output is correct
23 Correct 659 ms 246460 KB Output is correct
24 Correct 600 ms 227768 KB Output is correct
25 Correct 566 ms 209024 KB Output is correct