第 431 场周赛 - 力扣(LeetCode)
Q1 最长乘积等价子数组模拟即可
12345678910111213141516171819202122class Solution {public: typedef long long ll; int maxLength(vector<int>& nums) { ll n = nums.size(), ans = 1; for(int i = 0; i < n ; i++){ ll a = nums[i], b = nums[
2025-01-041.1k 字5 分钟
高并发内存池(2)
central cache申请内存也是一个哈希桶结构,映射规则与thread cache 类似,桶锁减小竞争。
central cache 哈希映射的spnlist, spanlist中挂着span,从span中取出对象给thread cache,这个过程是加锁的(桶锁)
spanlist中所有span都没有内存之后需要向 page cache 申请一个新的span对象给thread cache。 span用一个结构体来实现,span中的 use_count 记录分配了多少对象出去 use_count++。
释放内存当thread_cache过长或者线程销毁,则会将内存释放回central
[Dashboard - Codeforces Round 980 (Div. 2) - Codeforces)
A. Profitable Interest Rate思路:a - x >= b - 2x, 变形一下得 2 * a - b, 最小为0 最大为a 即可
12345678910111213141516171819#include <bits/stdc++.h>using namespace std;using ll = long long;typedef pair<int, int> pii;void solve() {
2025-01-01812 字4 分钟
Codeforces Round 886 (Div. 4)
[Dashboard - Codeforces Round 886 (Div. 4) - Codeforces)
新年快乐! 做个简单的
A. To My Critics12345678910111213141516171819#include <bits/stdc++.h>using namespace std;void solve() { int a, b, c; cin >> a >> b >> c; if(a + b >= 10 || b + c >= 10 || a + c >= 10) &
2024-12-311.1k 字6 分钟
Codeforces Round 927 (Div. 3)
Dashboard - Codeforces Round 927 (Div. 3) - Codeforces
A. Thorns and Coins思路:遇到@加一, 连续两个*结束循环
123456789101112131415161718192021222324#include <iostream>using namespace std;void solve() { int n; cin >> n; string s; cin >> s; int ans = 0; for(int i = 0; i <
2024-12-30820 字4 分钟
my_first_blog
CodeForces 1650A - Deletions of Two Adjacent Letters思路:给定一个字符串,进行任意次以下操作:选择字符串中的任意两个相邻字母 s并将它们从字符串中删除,使过程以长度为 1、由字母 c 组成的字符串结束。只需要判断字符串中是否存在这个字符,并且该字符的下表是偶数即可
1234567891011121314151617181920212223242526272829#include<iostream>using namespace std;int main(){ int t; cin >> t; while (t