LOADING

加载过慢请开启缓存,浏览器默认开启

Waiting for the dawn

daily 2

2023/7/31

CF 1367E

void solve() {
  int n, k;
  cin >> n >> k;
  vector<ll> cnt(26);
  function<bool(int, int)> check =
      [&](int total, int rep) {  // total: the number of current
        for (int i = 0; i < 26; ++i) {
          total -= cnt[i] / rep;
          if (total <= 0) return true;
        }
        return false;
      };
  string s;
  ll ans = 0;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    cnt[s[i] - 'a']++;
    ans = max(ans, cnt[s[i] - 'a']);
  }
  vector<int> fac;
  for (int i = 2; i <= k; ++i) {
    if (k % i == 0) {
      fac.push_back(i);
    }
  }

  for (int &f : fac) {
    int l = 1, r = n / f;  // 循环节的数量
    while (l <= r) {
      int mid = (l + r) >> 1;  //
      if (check(f, mid)) {
        ans = max(ans, 1ll * mid * f);
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
  }
  cout << ans << '\n';
  return;
}

CF 1363E



阅读全文

daily 2

2023/7/30

daily codeforces

阅读全文

daily 1

2023/7/29

CF 1335E2

void solve() {
  int n, ans = 0;
  cin >> n;
  vector<int> pos[MAXN];
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= 200; ++j) {
        cnt[i][j] = 0;
    }
  }
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    memcpy(cnt[i], cnt[i - 1], sizeof(cnt[i - 1]));
    cnt[i][a[i]]++;
    pos[a[i]].push_back(i);
  }
  for (int i = 1; i <= 200; ++i) {
    int sz = pos[i].size();
    ans = max(ans, sz);
    for (int j = 0; j < sz / 2; ++j) {
      int l = pos[i][j], r = pos[i][sz - j - 1] - 1;
      for (int k = 1; k <= 200; ++k) {
        int mid = cnt[r][k] - cnt[l][k];
        ans = max(ans, (j + 1) * 2 + mid);
      }
    }
  }
  cout << ans << '\n';
  return;
}
阅读全文

daily 2

2023/7/28

daily codeforces

阅读全文

daily 2

2023/7/27

daily codeforces

阅读全文

daily 2

2023/7/26

daily codeforces

阅读全文

daily 2

2023/7/25

daily codeforces

阅读全文

daily 2

2023/7/24

daily codeforces

阅读全文

daily 2

2023/7/23

daily codeforces

阅读全文

daily 2

2023/7/22

daily codeforces

阅读全文
1 ... 12 13 14 15 16 ... 30
avatar
Yanxin Xiang

愿有一天能和你最重要的人再次相逢