mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-09-04 01:01:43 +00:00
update
This commit is contained in:
parent
2e204e29b6
commit
27ecded092
47
src/8/26/P2782.cpp
Normal file
47
src/8/26/P2782.cpp
Normal 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
28
src/8/26/P5124.cpp
Normal 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";
|
||||
}
|
Loading…
Reference in New Issue
Block a user