Educational Codeforces Round 164 div2(Codeforce集 vp-2)

youhualiuh / 2024-04-24 / 原文

写的可以慢 重点是会这题 vp一下

A - Painting the Ribbon

思路(题意):

首先,Bob 同一颜色 Alice 则相反
我去看Bob的情况(no)
如果Bob想要同一颜色 也就是至少需要n-k个颜色 如果<这个说明我Bob就out了
所以我们尽量均匀分布的最大值即可得出最后的答案

Code:

#include<bits/stdc++.h>
  
using namespace std;
#define debug(x) cerr << #x << ": " << x << '\n';
  
void solve() {
  int n, m, k; cin >> n >> m >> k;
  int x = (n + m - 1) / m;
  cout << (x + k >= n ? "No\n" : "Yes\n"); 
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int T; cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}

  

B. Make It Ugly

 

思路:

给定一个美丽定义的数组,你要删除最小的可能使它不是这个数组,如果它删除了元素它还不是好数组,那么好,它get out。比如 2 2 2 2就是输出-1因为你输出谁都不肯能不是美丽的数组.题目是给你一个好数组叫你删除  

Code:

#include<bits/stdc++.h>
  
using namespace std;
#define debug(x) cerr << #x << ": " << x << '\n';

void solve() {
  int n; cin >> n;
  vector <int> a(n + 1);
  bool ok = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] != a[1]) ok = 1;
  }
  if (!ok) {
    cout << -1 << '\n';
    return ;
  } 
  int ans = n, r = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[1]) {
      ans = min(ans, i - r - 1);
      r = i;
    }
  } 
  cout << min(ans, n - r) << '\n'; 
  return ;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int T; cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}