fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
  4. #define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
  5. #define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
  6.  
  7. #define DEBUG(x) { cout << #x << " = "; cout << x << endl; }
  8. #define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
  9. #define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }
  10. using namespace std;
  11. int INP,AM,REACHEOF;
  12. const int BUFSIZE = (1<<12) + 17;
  13. char BUF[BUFSIZE+1], *inp=BUF;
  14. #define GETCHAR(INP) { \
  15.   if(!*inp && !REACHEOF) { \
  16.   memset(BUF,0,sizeof BUF);\
  17.   int inpzzz = fread(BUF,1,BUFSIZE,stdin);\
  18.   if (inpzzz != BUFSIZE) REACHEOF = true;\
  19.   inp=BUF; \
  20.   } \
  21.   INP=*inp++; \
  22. }
  23. #define DIG(a) (((a)>='0')&&((a)<='9'))
  24. #define GN(j) { \
  25.   AM=0;\
  26.   GETCHAR(INP); while(!DIG(INP) && INP!='-') GETCHAR(INP);\
  27.   if (INP=='-') {AM=1;GETCHAR(INP);} \
  28.   j=INP-'0'; GETCHAR(INP); \
  29.   while(DIG(INP)){j=10*j+(INP-'0');GETCHAR(INP);} \
  30.   if (AM) j=-j;\
  31. }
  32.  
  33. const int MN = 300111;
  34. const int oo = 1000111000;
  35.  
  36. int n, a, b, c1[MN], c2[MN];
  37. pair<int,int> x[MN];
  38.  
  39. int main() {
  40. ios :: sync_with_stdio(false);
  41. cin.tie(nullptr);
  42. if(fopen("recruitment.inp","r"))
  43. {
  44. freopen("recruitment.inp","r",stdin);
  45. freopen("recruitment.out","w",stdout);
  46. }
  47. FOR(i,1,n) cin >> x[i].first >> x[i].second;
  48. sort(x+1, x+n+1);
  49. FOR(i,1,n) {
  50. c1[i] = c1[i-1] + (x[i].second == 1);
  51. c2[i] = c2[i-1] + (x[i].second == 2);
  52. }
  53. int best = oo;
  54. FOR(i,1,n) {
  55. if (c1[i] < a || c2[i] < b) continue;
  56. int left = 1, right = i, res = 1;
  57. while (left <= right) {
  58. int mid = (left + right) >> 1;
  59. if (c1[i] - c1[mid-1] >= a && c2[i] - c2[mid-1] >= b) {
  60. res = mid;
  61. left = mid + 1;
  62. }
  63. else right = mid - 1;
  64. }
  65. best = min(best, x[i].first - x[res].first);
  66. }
  67. cout << "2" << endl << "114";
  68. return 0;
  69. }
  70.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
2
114