Submission #586369

#TimeUsernameProblemLanguageResultExecution timeMemory
586369hibikiLightning Rod (NOI18_lightningrod)C++11
100 / 100
1990 ms79764 KiB
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second

stack<pair<int,int> > s;

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        int x, y;
        scanf("%d %d",&x,&y);
        while(!s.empty() && x - s.top().f <= abs(y - s.top().s) && y > s.top().s)
            s.pop();
        if(s.empty() || x - s.top().f > abs(y - s.top().s))
            s.push({x, y});
    }
    printf("%d\n",s.size());
}

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:23:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::stack<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wformat=]
   23 |     printf("%d\n",s.size());
      |             ~^
      |              |
      |              int
      |             %ld
lightningrod.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
lightningrod.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d %d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...