# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104249 | dupreez | Lightning Rod (NOI18_lightningrod) | C++14 | 2068 ms | 116856 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#define mk make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007,N=10000010;
int n,mxv,st[N],sti;
void push(int v1) {
st[sti] = v1;
sti++;
}
void pop() {
sti--;
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int v1, v2;
scanf("%d%d", &v1,&v2);
if (i == 1) {
mxv = v1 + v2;
push(v1 - v2);
}
else if (mxv < v1 + v2) {
while (sti!=0 && st[sti-1] >= v1 - v2)pop();
push(v1 - v2);
mxv = v1 + v2;
}
}
cout << sti << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |