This commit is contained in:
Zengtudor 2025-08-26 12:49:41 +08:00
parent 2e204e29b6
commit 27ecded092
2 changed files with 75 additions and 0 deletions

47
src/8/26/P2782.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <ostream>
#include <utility>
#include <vector>
using ll = int64_t;
std::ostream& operator<<(std::ostream& os, const std::pair<ll, ll>& p){
os << "{ " << p.first << ", " << p.second << " }";
return os;
}
#define pa(a)do{for(auto v:(a)){std::cout<<v<<", ";}std::cout<<"\n";}while(0)
int main(){
std::iostream::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
std::cin >> n;
std::vector<ll> c(n);
std::vector<std::pair<ll, ll>> input(n);
for (ll i = 0; i < n; i++){
std::cin >> input[i].first >> input[i].second;
}
std::sort(input.begin(), input.end());
for (ll i = 0; i < input.size(); i++){
c[i] = input[i].second;
}
std::vector<ll> f;
f.reserve(n);
for (ll x : c) {
auto it = std::lower_bound(f.begin(), f.end(), x);
if (it == f.end()) {
f.push_back(x);
} else {
*it = x;
}
}
std::cout << f.size() << std::endl;
return 0;
}

28
src/8/26/P5124.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <algorithm>
#include <iostream>
#include <istream>
#include <numeric>
#include <vector>
using ll = int64_t;
#define pv(v)do{std::cout<<#v<<": "<<(v)<<"\n";}while(0)
int main(){
std::iostream::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,k;
std::cin>>n>>k;
std::vector<ll> v(n);
for(ll&i:v){
std::cin>>i;
}
std::sort(v.begin(),v.end());
ll teams=n/k,last=n%k;
ll teamssum = std::accumulate(v.rbegin(),v.rbegin()+teams,0);
// pv(teams);
// pv(teamssum);
// pv(last);
std::cout<<(last * (*(v.rbegin()+teams)) + teamssum*k)<<"\n";
}