因为火锅导致错过的上分机会😂,赛后发现人均AC5题

1430A. Number of Apartments

暴力搜索

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. ll n;
  5. void solve() {
  6. cin >> n;
  7. //bool flag = false;
  8. for (int i = 0; i * 3 <= n; i++)
  9. for (int j = 0; j * 5 <= n; j++)
  10. if ((n - i * 3 - j * 5) % 7 == 0) {
  11. cout << i << " " << j << " " << (n - i * 3 - j * 5) / 7 << endl;
  12. return;
  13. }
  14. cout << -1 << endl;
  15. }
  16. int main() {
  17. //freopen("in.txt", "r", stdin);
  18. ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  19. int _; cin >> _; while (_--)solve();
  20. }

1430B. Barrels

对水桶排序,累加后面k个水量即可

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int N = 2e5 + 100;
  5. ll n, k, a[N];
  6. void solve() {
  7. cin >> n >> k;
  8. for (ll i = 0; i < n; i++) cin >> a[i];
  9. sort(a, a + n);ll l = a[n - 1];
  10. for (ll i = n - 2; i >= n - k - 1; i--) { l += a[i]; }cout << l << endl;
  11. }
  12. int main() {
  13. int _; cin >> _; while (_--)solve();
  14. }

1430C. Numbers on Whiteboard

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int N = 2e5 + 100;
  5. ll n, k, a[N], _, m;
  6. void solve() {
  7. cin >> n; m = n; k = n - 1;
  8. cout << 2 << '\n';
  9. for (int i = 2; i <= n; ++i) {
  10. cout << k << ' ' << m << '\n';
  11. m = (k + m + 1) / 2; --k;
  12. }
  13. }
  14. int main() {
  15. int _; cin >> _; while (_--)solve();
  16. }

1430D. String Deletion

1430E. String Reversal