답안 #183943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
183943 2020-01-10T08:30:30 Z duttaditya18 Lightning Rod (NOI18_lightningrod) C++17
80 / 100
2000 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second

#ifndef ONLINE_JUDGE
#define getchar_unlocked getchar
#endif

void fastscan(int &x)
{
    bool neg=false;
    register int c;
    x =0;
    c=getchar_unlocked();
    if(c=='-')
    {
        neg = true;
        c=getchar_unlocked();
    }
    for(;(c>47 && c<58);c=getchar_unlocked())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n;
    fastscan(n);

    // x, y
    int x, y;
    pair<int, int> p[n + 1];

    for(int i = 1; i <= n; i++)
    {
        fastscan(p[i].fi);
        fastscan(p[i].se);
    }

    int suf[n + 2] = {};
    int prf[n + 2] = {};

    prf[0] = INT_MIN;
    prf[n + 1] = INT_MIN;

    suf[0] = INT_MAX;
    suf[n + 1] = INT_MAX;

    for(int i = 1; i <= n; i++)
        prf[i] = max(prf[i - 1], p[i].fi + p[i].se);


    for(int i = n; i >= 1; i--)
        suf[i] = min(suf[i + 1], p[i].fi - p[i].se);


    int ans = n;
    for(int i = 1; i <= n; i++)
        ans -= ((p[i].fi + p[i].se <= prf[i - 1]) || (p[i].fi - p[i].se >= suf[i + 1]));
    cout << ans << endl;
}

Compilation message

lightningrod.cpp: In function 'void fastscan(int&)':
lightningrod.cpp:15:18: warning: ISO C++1z does not allow 'register' storage class specifier [-Wregister]
     register int c;
                  ^
lightningrod.cpp: In function 'int main()':
lightningrod.cpp:38:9: warning: unused variable 'x' [-Wunused-variable]
     int x, y;
         ^
lightningrod.cpp:38:12: warning: unused variable 'y' [-Wunused-variable]
     int x, y;
            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1839 ms 158028 KB Output is correct
2 Correct 1848 ms 262144 KB Output is correct
3 Correct 1785 ms 257188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 380 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 1 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 380 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 1 ms 376 KB Output is correct
14 Correct 56 ms 4828 KB Output is correct
15 Correct 56 ms 5076 KB Output is correct
16 Correct 43 ms 4856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1653 ms 156712 KB Output is correct
2 Correct 1706 ms 252520 KB Output is correct
3 Correct 1615 ms 246384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1839 ms 158028 KB Output is correct
2 Correct 1848 ms 262144 KB Output is correct
3 Correct 1785 ms 257188 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 380 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 1 ms 376 KB Output is correct
17 Correct 56 ms 4828 KB Output is correct
18 Correct 56 ms 5076 KB Output is correct
19 Correct 43 ms 4856 KB Output is correct
20 Correct 1653 ms 156712 KB Output is correct
21 Correct 1706 ms 252520 KB Output is correct
22 Correct 1615 ms 246384 KB Output is correct
23 Execution timed out 2055 ms 206612 KB Time limit exceeded
24 Halted 0 ms 0 KB -