#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <cassert>
#include <random>
#include <time.h>
using namespace std;
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int mod2 = 998244353;
void fact_init(int n, int md);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);
vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n, int md){
fact.resize(n+5);
inv_fact.resize(n+5);
fact[0] = inv_fact[0] = 1;
for(int i = 1; i <= n; i++){
fact[i] = (fact[i-1] * i) % md;
inv_fact[i] = exp(fact[i], md-2, md);
}
}
ll exp(ll taban, ll us, ll md) {
ll carpan = taban % md;
if(carpan == 0) return 0;
ll temp = us;
ll res = 1;
while(temp){
if(temp % 2) res = (res*carpan) % md;
temp /= 2;
carpan = (carpan*carpan) % md;
}
return res;
}
ll ebob(ll a, ll b){
if(!a)return b;
return ebob(b%a, a);
}
ll ekok(ll a, ll b){
return (a*b)/ebob(a, b);
}
ll komb(int a, int b, int md){
if(a < b) return 0;
return fact[a] * (inv_fact[a-b] * inv_fact[b] % md) % md;
}
ll mul(ll a, ll b, int md){
return a*b % md;
}
const int N = 1e5 + 5;
struct P{
int diff, sum;
bool operator<(const P& o) const{
return diff < o.diff;
}
};
int main(){
ios::sync_with_stdio(false); cin.tie(NULL);
set<P> st;
multiset<int> sums;
int n; cin>>n;
for(int i = 0; i < n; i++){
int x, y; cin>>x>>y;
if(!sums.empty() && *sums.rbegin() >= x+y) continue;
while(!st.empty() && st.begin()->diff <= y-x){
sums.erase(sums.find(st.begin()->sum));
st.erase(st.begin());
}
st.insert(P{y-x, y+x});
sums.insert(y+x);
}
cout<<st.size()<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1965 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
43 ms |
3976 KB |
Output is correct |
15 |
Correct |
45 ms |
3704 KB |
Output is correct |
16 |
Correct |
93 ms |
10872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2098 ms |
218988 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1965 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |