Submission #586368

# Submission time Handle Problem Language Result Execution time Memory
586368 2022-06-30T07:50:10 Z hibiki Lightning Rod (NOI18_lightningrod) C++11
80 / 100
2000 ms 166340 KB
#include<bits/stdc++.h>
using namespace std;

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

stack<int> s;
vector<pair<int,int> > v;

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

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:25:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::stack<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   25 |     printf("%d\n",s.size());
      |             ~^
      |              |
      |              int
      |             %ld
lightningrod.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
lightningrod.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d %d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1927 ms 166204 KB Output is correct
2 Correct 1814 ms 166340 KB Output is correct
3 Correct 1741 ms 166244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 212 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 212 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 212 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 300 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 352 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 212 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 300 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 352 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 53 ms 2732 KB Output is correct
15 Correct 48 ms 2676 KB Output is correct
16 Correct 38 ms 2752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1882 ms 153528 KB Output is correct
2 Correct 1855 ms 153772 KB Output is correct
3 Correct 1872 ms 153556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1927 ms 166204 KB Output is correct
2 Correct 1814 ms 166340 KB Output is correct
3 Correct 1741 ms 166244 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 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 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 352 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 53 ms 2732 KB Output is correct
18 Correct 48 ms 2676 KB Output is correct
19 Correct 38 ms 2752 KB Output is correct
20 Correct 1882 ms 153528 KB Output is correct
21 Correct 1855 ms 153772 KB Output is correct
22 Correct 1872 ms 153556 KB Output is correct
23 Execution timed out 2012 ms 133020 KB Time limit exceeded
24 Halted 0 ms 0 KB -