結果

問題 No.1137 Circles
ユーザー beetbeet
提出日時 2020-07-30 16:42:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 362 ms / 2,000 ms
コード長 2,195 bytes
コンパイル時間 3,120 ms
コンパイル使用メモリ 226,720 KB
実行使用メモリ 28,892 KB
最終ジャッジ日時 2023-09-17 06:39:51
合計ジャッジ時間 7,163 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 330 ms
27,228 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 170 ms
18,128 KB
testcase_04 AC 249 ms
23,096 KB
testcase_05 AC 38 ms
7,492 KB
testcase_06 AC 288 ms
24,856 KB
testcase_07 AC 130 ms
15,476 KB
testcase_08 AC 313 ms
25,644 KB
testcase_09 AC 82 ms
11,936 KB
testcase_10 AC 147 ms
16,724 KB
testcase_11 AC 179 ms
18,528 KB
testcase_12 AC 362 ms
28,892 KB
testcase_13 AC 90 ms
12,520 KB
testcase_14 AC 355 ms
28,408 KB
testcase_15 AC 105 ms
13,764 KB
testcase_16 AC 173 ms
18,408 KB
testcase_17 AC 16 ms
5,204 KB
testcase_18 AC 282 ms
25,324 KB
testcase_19 AC 98 ms
13,112 KB
testcase_20 AC 67 ms
10,600 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0