Submission #710126

# Submission time Handle Problem Language Result Execution time Memory
710126 2023-03-15T04:56:56 Z ToroTN Lightning Rod (NOI18_lightningrod) C++14
100 / 100
1941 ms 247216 KB
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
int n,x[10000005],y[10000005],hsh[10000005],ans=0;
stack<pair<int,int> > stk;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]);
    for(int i=1;i<=n;i++)
    {
        while(!stk.empty())
        {
            if(y[i]-x[i]>=stk.top().X)
            {
                stk.pop();
            }else
            {
                break;
            }
        }
        stk.push({y[i]-x[i],i});
    }
    while(!stk.empty())
    {
        ++hsh[stk.top().Y];
        stk.pop();
    }
    for(int i=n;i>=1;i--)
    {
        while(!stk.empty())
        {
            if(y[i]+x[i]>=stk.top().X)
            {
                stk.pop();
            }else
            {
                break;
            }
        }
        stk.push({y[i]+x[i],i});
    }
    while(!stk.empty())
    {
        if(hsh[stk.top().Y]==1)++ans;
        stk.pop();
    }
    printf("%d\n",ans);
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
lightningrod.cpp:10:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1644 ms 193552 KB Output is correct
2 Correct 1642 ms 236244 KB Output is correct
3 Correct 1652 ms 222952 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 320 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 39 ms 2380 KB Output is correct
15 Correct 44 ms 2552 KB Output is correct
16 Correct 37 ms 3276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1669 ms 178472 KB Output is correct
2 Correct 1695 ms 178480 KB Output is correct
3 Correct 1593 ms 180348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1644 ms 193552 KB Output is correct
2 Correct 1642 ms 236244 KB Output is correct
3 Correct 1652 ms 222952 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 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 39 ms 2380 KB Output is correct
18 Correct 44 ms 2552 KB Output is correct
19 Correct 37 ms 3276 KB Output is correct
20 Correct 1669 ms 178472 KB Output is correct
21 Correct 1695 ms 178480 KB Output is correct
22 Correct 1593 ms 180348 KB Output is correct
23 Correct 1882 ms 84548 KB Output is correct
24 Correct 1941 ms 245440 KB Output is correct
25 Correct 1880 ms 247216 KB Output is correct