Submission #1251324

#TimeUsernameProblemLanguageResultExecution timeMemory
1251324mngoc._.Advertisement 2 (JOI23_ho_t2)C++20
59 / 100
42 ms9392 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)
#define FOD(i, r, l) for (int i = (r), _l = (l); i >= _l; i--)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define Konosuba tuple<int , int , int, int>
#define fi first
#define se second

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const int block = 330;
const int LOG = 30;
const int MAXN = 1e6 + 1;
const int INF = 1e14;
const int base = 311;


template<class A, class B>
bool umin(A& var, const B& val){ return (val < var) ? (var = val, true) : false; }
template<class A, class B>
bool umax(A& var, const B& val){ return (var < val) ? (var = val, true) : false; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class X, class Y> int random(const int& l, const int& r) {
  return uniform_int_distribution<int>(l,r)(rng);
}

priority_queue<pii , vector<pii>> pq;
pii a[N];
int n; 
pii nodes[N];
struct node{
	int x , y , idx;
};
vector<node> Nodes;
bool cmp(const node& a , const node& b){
	if(a.x != b.x) return a.x < b.x;
	return a.y > b.y;
}
void solve(void){
	cin >> n;
	FOR(i , 1 , n) cin >> a[i].first >> a[i].second;
	FOR(i , 1 , n){
		Nodes.push_back({a[i].first - a[i].second , a[i].first + a[i].second , i});
	}
	sort(Nodes.begin() , Nodes.end() , cmp);
	int res = 0;
	int v = -INF;
	FOR(i , 0 , Nodes.size() - 1){
	    if(Nodes[i].y > v) {
	    	v = Nodes[i].y;
	    	res++;
		}
	}
	cout << res;
	
	
	
	
}




signed main(void) {
    if (fopen("smod.INP", "r")) {
        freopen("smod.INP", "r", stdin);
        freopen("smod.OUT", "w", stdout);
    } 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testCase = 1; //cin >> testCase;
    FOR(i , 1 , testCase){
        solve();
    }

    cerr << "Time elapsed: " << TIME << "s.\n";
    return (0);
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:72:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         freopen("smod.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen("smod.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...