답안 #313303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
313303 2020-10-15T17:13:23 Z kaplanbar Lightning Rod (NOI18_lightningrod) C++17
66 / 100
2000 ms 74608 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 1e7+1;
int n;
bool v[N];
pair<int,int> a[N];
int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++) {
      scanf("%d %d", &a[i].first, &a[i].second);
      //cin >> a[i].first >> a[i].second;
    }
    int mx = -2000000000;
    for(int i = 0; i < n; i++) {
      int val = a[i].first + a[i].second;
      if(mx >= val) {
        v[i] = 1;
      }
      else {
        mx = val;
      }
    }
    mx = -2000000000;
    for(int i = n - 1; i >= 0; i--) {
      int val = a[i].second - a[i].first;
      if(mx >= val) {
        v[i] = 1;
      }
      else {
        mx = val;
      }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) ans += v[i];
    //cout << n-ans;
    printf("%d",n-ans);
    return 0;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:13:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |       scanf("%d %d", &a[i].first, &a[i].second);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2089 ms 69544 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 71 ms 1912 KB Output is correct
15 Correct 64 ms 2040 KB Output is correct
16 Correct 56 ms 1912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2083 ms 74608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2089 ms 69544 KB Time limit exceeded
2 Halted 0 ms 0 KB -