답안 #710123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710123 2023-03-15T04:55:18 Z ToroTN Lightning Rod (NOI18_lightningrod) C++14
66 / 100
2000 ms 262144 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())
    {
        ++hsh[stk.top().Y];
        stk.pop();
    }
    for(int i=1;i<=n;i++)if(hsh[i]==2)++ans;
    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]);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2013 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 324 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 324 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 50 ms 5976 KB Output is correct
15 Correct 72 ms 5884 KB Output is correct
16 Correct 68 ms 6048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1959 ms 262144 KB Output is correct
2 Execution timed out 2021 ms 262144 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2013 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -