結果
問題 |
No.1137 Circles
|
ユーザー |
![]() |
提出日時 | 2020-07-30 16:42:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 513 ms / 2,000 ms |
コード長 | 2,195 bytes |
コンパイル時間 | 4,071 ms |
コンパイル使用メモリ | 217,952 KB |
最終ジャッジ日時 | 2025-01-12 07:59:49 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#define PROBLEM "https://yukicoder.me/problems/4778" #include<bits/stdc++.h> using namespace std; #define call_from_test #ifndef call_from_test #include <bits/stdc++.h> using namespace std; #endif //BEGIN CUT HERE template<typename T> vector<T> add(vector<T> vs,vector<T> as){ assert(vs.size()==as.size()); for(int i=0;i<(int)vs.size();i++) vs[i]+=as[i]; return vs; } template<typename T> vector<T> add(vector<T> vs,T a){ return add(vs,vector<T>(vs.size(),a)); } template<typename T> vector<T> mul(vector<T> vs,vector<T> as){ assert(vs.size()==as.size()); for(int i=0;i<(int)vs.size();i++) vs[i]*=as[i]; return vs; } template<typename T> vector<T> mul(vector<T> vs,T a){ return mul(vs,vector<T>(vs.size(),a)); } template<typename T, typename ...Ts> vector<T> near(vector<T> vs,Ts... ts){ vector<T> rs; rs.reserve(vs.size()*sizeof...(ts)); auto append=[&](auto a){ auto ws=add(vs,a); for(auto w:ws) rs.emplace_back(w); }; initializer_list<int>{(void(append(ts)),0)...}; return rs; } //END CUT HERE #ifndef call_from_test signed main(){ return 0; } #endif #ifndef call_from_test #include <bits/stdc++.h> using namespace std; #endif //BEGIN CUT HERE template<typename V> V compress(V vs){ sort(vs.begin(),vs.end()); vs.erase(unique(vs.begin(),vs.end()),vs.end()); return vs; } template<typename T> map<T, int> dict(const vector<T> &vs){ map<T, int> res; for(int i=0;i<(int)vs.size();i++) res[vs[i]]=i; return res; } map<char, int> dict(const string &s){ return dict(vector<char>(s.begin(),s.end())); } //END CUT HERE #ifndef call_from_test //INSERT ABOVE HERE signed main(){ return 0; } #endif #undef call_from_test signed main(){ cin.tie(0); ios::sync_with_stdio(0); const char newl = '\n'; int n; cin>>n; vector<int> xs(n),rs(n); for(int i=0;i<n;i++) cin>>xs[i]>>rs[i]; xs=mul(xs,2); rs=mul(rs,2); auto vs=compress(near(near(xs,0,rs,mul(rs,-1)),-1,0,1)); auto dc=dict(vs); vector<int> sm(vs.size(),0); for(int i=0;i<n;i++){ sm[dc[xs[i]-rs[i]+1]]++; sm[dc[xs[i]+rs[i]]]--; } for(int i=1;i<(int)vs.size();i++) sm[i]+=sm[i-1]; cout<<*max_element(sm.begin(),sm.end())<<newl; return 0; }