Submission #147299

# Submission time Handle Problem Language Result Execution time Memory
147299 2019-08-28T18:43:07 Z JovanK26 Lightning Rod (NOI18_lightningrod) C++14
100 / 100
773 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;
int x[10000001];
int y[10000001];
int pref[10000001];
int suf[10000001];
int rez=0;
static char buf[1 << 19];
static int idx = 0;
static int bytes = 0;
static inline int _read() {
    if (!bytes || idx == bytes) {
        bytes = (int)fread(buf, sizeof(buf[0]), sizeof(buf), stdin);
        idx = 0;
    }
    return buf[idx++];
}
static inline int _readInt() {
    int x = 0, s = 1;
    int c = _read();
    while (c <= 32) c = _read();
    if (c == '-') s = -1, c = _read();
    while (c > 32) x = 10 * x + (c - '0'), c = _read();
    if (s < 0) x = -x;
    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    n=_readInt();
    for(int i=0;i<n;i++)
    {
        x[i]=_readInt();
        y[i]=_readInt();
    }
    pref[0]=x[0]+y[0];
    for(int i=1;i<n;i++)
    {
        pref[i]=max(pref[i-1],x[i]+y[i]);
    }
    suf[n-1]=y[n-1]-x[n-1];
    for(int i=n-2;i>=0;i--)
    {
        suf[i]=max(suf[i+1],y[i]-x[i]);
    }
    for(int i=0;i<n;i++)
    {
        if(!i && suf[i]>suf[i+1])rez++;
        else if(i==n-1 && pref[i]>pref[i-1])rez++;
        else if(pref[i]>pref[i-1] && suf[i]>suf[i+1])
        {
            rez++;
        }
    }
    cout << rez;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 542 ms 183712 KB Output is correct
2 Correct 541 ms 262144 KB Output is correct
3 Correct 526 ms 257404 KB Output is correct
# Verdict Execution time Memory 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 3 ms 376 KB Output is correct
5 Correct 2 ms 372 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory 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 3 ms 376 KB Output is correct
5 Correct 2 ms 372 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 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory 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 3 ms 376 KB Output is correct
5 Correct 2 ms 372 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 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory 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 3 ms 376 KB Output is correct
5 Correct 2 ms 372 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 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 18 ms 7292 KB Output is correct
15 Correct 17 ms 7288 KB Output is correct
16 Correct 18 ms 6520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 523 ms 179632 KB Output is correct
2 Correct 544 ms 252880 KB Output is correct
3 Correct 518 ms 246880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 542 ms 183712 KB Output is correct
2 Correct 541 ms 262144 KB Output is correct
3 Correct 526 ms 257404 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 3 ms 376 KB Output is correct
8 Correct 2 ms 372 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 18 ms 7292 KB Output is correct
18 Correct 17 ms 7288 KB Output is correct
19 Correct 18 ms 6520 KB Output is correct
20 Correct 523 ms 179632 KB Output is correct
21 Correct 544 ms 252880 KB Output is correct
22 Correct 518 ms 246880 KB Output is correct
23 Correct 773 ms 262144 KB Output is correct
24 Correct 750 ms 262144 KB Output is correct
25 Correct 692 ms 262144 KB Output is correct