This commit is contained in:
Zengtudor 2024-11-27 21:38:52 +08:00
parent 87cd0ebf71
commit 4d387280dc
3 changed files with 114 additions and 0 deletions

13
src/11/27/P3951.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <cstdint>
#include <iostream>
using namespace std;
using ll = int64_t;
ll a,b;
int main(){
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
cin>>a>>b;
cout<<(a*b-(a+b))<<'\n';
}

74
src/11/c2/P1048.cpp Normal file
View File

@ -0,0 +1,74 @@
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
using std::cin, std::cout, std::max;
constexpr size_t MAX_N = 500005;
int main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int arr[MAX_N];
int len[MAX_N];
int n = 0;
int ans1 = 0;
int ans2 = 0;
while(cin >> arr[n]){
len[n] = 1;
n++;
}
for(int i = 0; i < n; i++){
for(int j = 0; j < i; j++){
if(arr[j] >= arr[i]){
if(len[i] < len[j] + 1){
len[i] = len[j] + 1;
}
}
}
if(ans1 < len[i]){
ans1 = len[i];
}
}
std::vector<int> systems;
for(int i = 0; i < n; i++){
bool isOk = false;
for(int j = 0; j < systems.size(); j++){
if(systems[j] >= arr[i]){
systems[j] = arr[i];
isOk = true;
break;
}
}
if(!isOk){
systems.emplace_back(arr[i]);
}
}
ans2 = systems.size();
cout << ans1 << "\n" << ans2 << "\n";
return 0;
}

27
src/11/c3/P1047.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <bitset>
#include <cstdint>
#include <iostream>
#include <istream>
using namespace std;
using ll = int64_t;
const ll maxn=1e4+5;
ll l,m,ans;
bitset<maxn> vis;
int main(){
iostream::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>l>>m;
for(ll i=1;i<=m;i++){
ll a,b;
cin>>a>>b;
for(ll j=a;j<=b;j++){
if(!vis[j]){
vis[j]=true;
ans++;
}
}
}
cout<<(l-ans+1)<<'\n';
}