CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!)+AtCoder Beginner Contest 294
AtCoder Beginner Contest 294
![](https://i-blog.csdnimg.cn/blog_migrate/db35a98639d8bdc207b5364ca71fba19.png)
D
#include <bits/stdc++.h>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define ls (u << 1)
#define rs (u << 1 | 1)
#define PI acos(-1)
#define int long long
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e6;
const int mod=1e9+7;
int a[N],n,m;
struct XY
{
int x;
int id;
}xy[N];
bool cmp(XY aa,XY bb)
{
return aa.x<bb.x;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int T=1;
//cin>>T;
while(T--)
{
cin>>n>>m;
map<int,int>mp;
int cnt=1;
vector<int>v;
set<int>s;
for(int i=1;i<=m;i++)
{
int op;
cin>>op;
if(op==1)
{
s.insert(cnt);
cnt++;
}
else if(op==2)
{
int x;
cin>>x;
s.erase(x);
}
else
{
v.push_back(*s.begin());
}
}
sort(v.begin(),v.end());
for(auto x:v)cout<<x<<"\n";
}
return 0;
}
E
#include <bits/stdc++.h>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define ls (u << 1)
#define rs (u << 1 | 1)
#define PI acos(-1)
#define int long long
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e6;
const int mod=1e9+7;
int a[N],n,m;
int v1[N],l1[N],v2[N],l2[N];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int T=1;
//cin>>T;
while(T--)
{
int L,n1,n2;
cin>>L>>n1>>n2;
for(int i=1;i<=n1;i++)
{
cin>>v1[i]>>l1[i];
}
for(int i=1;i<=n2;i++)
{
cin>>v2[i]>>l2[i];
}
int len1=1,len2=1;
int cnt=1;
int ans=0;
for(int i=1;i<=n1;i++)
{
int ll=len1,rr=len1+l1[i]-1;
while(len2+l2[cnt]-1<=rr)
{
if(v2[cnt]==v1[i])
{
ans+=l2[cnt];
}
len2+=l2[cnt];
cnt++;
}
if(len2<=rr)
{
if(v2[cnt]==v1[i])
{
ans+=rr-len2+1;
}
l2[cnt]-=rr-len2+1;
len2=rr+1;
}
len1=len1+l1[i];
}
cout<<ans;
}
return 0;
}
F:二分
#include <bits/stdc++.h>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define ls (u << 1)
#define rs (u << 1 | 1)
#define PI acos(-1)
#define int long long
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e6;
const int mod=1e9+7;
int n,m,k;
const long double eps=1e-14;
pair<int,int>pa[N],pb[N];
long double a[N],b[N];
bool check(long double x)
{
for(int i=1;i<=n;i++)
{
a[i]=(1-x)*pa[i].first-x*pa[i].second;
}
for(int i=1;i<=m;i++)
{
b[i]=(x-1)*pb[i].first+x*pb[i].second;
}
sort(a+1,a+1+n);
sort(b+1,b+1+m);
int num=0,cnt=1;
for(int i=1;i<=n;i++)
{
while(cnt<=m&&b[cnt]<=a[i])cnt++;
num+=cnt-1;
}
return num>=k;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int T=1;
//cin>>T;
while(T--)
{
cin>>n>>m>>k;
cout << fixed << setprecision(15);
for(int i=1;i<=n;i++)
{
cin>>pa[i].fi>>pa[i].se;
}
for(int i=1;i<=m;i++)
{
cin>>pb[i].fi>>pb[i].se;
}
long double l=0,r=1;
while(r-l>=eps)
{
long double mid=(l+r)/2;
if(check(mid))
l=mid+eps;
else r=mid-eps;
}
cout<<l*(100.0);
}
return 0;
}
G:好像是个树剖,以后复习树剖再补
CodeTON Round 2
ABC比较常规,D题是个强推式子的数学题,很答辩(说明推式子观察能力还不够)
![](https://i-blog.csdnimg.cn/blog_migrate/4fee434f3e2397f70e382f23231bdbff.png)