# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1139845 | fcmalkcin | Lightning Rod (NOI18_lightningrod) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
stack<pair<ll,ll>> st;
signed main(){
ll n;
cin >> n;
for (ll i = 0;i<n;i++){
ll x,y;
cin >> x >> y;
bool checkAdd = true;
while (true){
if (st.size() == 0){
st.push({x,y});
checkAdd = false;
break;
}
ll sx = st.top().first, sy = st.top().second;
if (x-sx<=sy-y) {
checkAdd = false;
break;
}
else if (x-sx <=y-sy) {
st.pop();
}
else {
break;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |