Submission #696817

# Submission time Handle Problem Language Result Execution time Memory
696817 2023-02-07T10:40:45 Z tsumondai Lightning Rod (NOI18_lightningrod) C++14
100 / 100
1982 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;
stack<pair<int, int>> stk;
vector<pair<int, int>> temp;

int main() {
    cin.tie(0)->sync_with_stdio(false);
    //freopen("thunder.inp", "r", stdin);
    //freopen("thunder.out", "w", stdout);
    int n;
	cin >> n;
	for (int i=1; i<=n; i++) {
        int x,y;
        cin >> x >> y;
        temp.push_back({x,y});
	}
	sort(temp.begin(), temp.end());
	for (int i=0; i<n; i++) {
		int x,y;
		x=temp[i].first; y=temp[i].second;
		if(stk.empty()) stk.push({x, y});
		else
		{
			int h = stk.top().second - x + stk.top().first;
			if(h >= y) continue ;
			while(!stk.empty())
			{
				int h = y - x + stk.top().first;
				if(h >= stk.top().second) stk.pop();
				else break ;
			}
			stk.push({x, y});
		}
	}
	cout << stk.size();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1799 ms 262144 KB Output is correct
2 Correct 1761 ms 262144 KB Output is correct
3 Correct 1800 ms 260144 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 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 0 ms 212 KB Output is correct
7 Correct 0 ms 316 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 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 0 ms 212 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 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 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 0 ms 212 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 328 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 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 0 ms 212 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 42 ms 5404 KB Output is correct
15 Correct 43 ms 5304 KB Output is correct
16 Correct 38 ms 5136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1773 ms 225704 KB Output is correct
2 Correct 1830 ms 225448 KB Output is correct
3 Correct 1796 ms 199704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1799 ms 262144 KB Output is correct
2 Correct 1761 ms 262144 KB Output is correct
3 Correct 1800 ms 260144 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 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 0 ms 212 KB Output is correct
10 Correct 0 ms 316 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 320 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 42 ms 5404 KB Output is correct
18 Correct 43 ms 5304 KB Output is correct
19 Correct 38 ms 5136 KB Output is correct
20 Correct 1773 ms 225704 KB Output is correct
21 Correct 1830 ms 225448 KB Output is correct
22 Correct 1796 ms 199704 KB Output is correct
23 Correct 1965 ms 262144 KB Output is correct
24 Correct 1982 ms 262144 KB Output is correct
25 Correct 1860 ms 257524 KB Output is correct