Compare commits

..

2 Commits

Author SHA1 Message Date
6e9562d5cb feat: 添加两个新的算法题目解决方案文件
添加 valid-triangle-number.cpp 和 P11231.cpp 两个文件,分别包含三角形数验证问题和P11231问题的解决方案
2025-09-26 16:41:14 +08:00
e8ed12ddcd docs(P7914): 移除冗余的long long类型注释 2025-09-26 12:32:50 +08:00
3 changed files with 46 additions and 1 deletions

View File

@ -5,7 +5,6 @@
using namespace std; using namespace std;
// 使用 long long 防止中间结果溢出
using ll = long long; using ll = long long;
const int MOD = 1e9 + 7; const int MOD = 1e9 + 7;

33
src/9/26/P11231.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <istream>
#include <map>
using ll = int64_t;
ll n;
std::map<ll, ll> r;
int main(){
std::iostream::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin>>n;
for(ll i=1;i<=n;i++){
ll tmp;
std::cin>>tmp;
r[tmp]++;
}
auto idx = r.begin();
ll lessn=idx->second;
idx++;
ll ans=0;
for(;idx!=r.end();idx++){
ll candel = std::min(idx->second,lessn);
lessn-=candel;
lessn+=idx->second;
ans+=candel;
}
std::cout<<n-ans<<"\n";
}

View File

@ -0,0 +1,13 @@
#include <cstdint>
#include <cstdlib>
#include <vector>
using namespace std;
class Solution {
public:
using ll = int64_t;
int triangleNumber(vector<int>& nums) {
}
};
int main(){}