# 题解 | #邂逅#

https://ac.nowcoder.com/acm/contest/80283/A

# A

``````#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define lowbit(x) ((x)&(-(x)))
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define maxheap(x) priority_queue<x,vector<x>,less<x> >
#define minheap(x) priority_queue<x,vector<x>,greater<x> >
#define endl '\n'
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef long long ll;
typedef unsigned long long ull;
//#define mod 1000000009
//#define mod 1000000007

int main()
{
int n;
cin>>n;
map<string,string> q;
int i;
for(i=1;i<=n;i++)
{
string s,t;
cin>>s>>t;
q[s]=t;
}
if(q.count("alicespring"))
cout<<q["alicespring"];
else cout<<-1;
return 0;
}
``````

# B

``````#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define lowbit(x) ((x)&(-(x)))
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define maxheap(x) priority_queue<x,vector<x>,less<x> >
#define minheap(x) priority_queue<x,vector<x>,greater<x> >
#define endl '\n'
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef long long ll;
typedef unsigned long long ull;
//#define mod 1000000009
//#define mod 1000000007

int main()
{
ll h,y,n;
cin>>h>>y>>n;
double ans=1.0*y*n/(h-y);
printf("%.0lf",ans);
return 0;
}
``````

# C

《你的名字》女主角宫水三叶的罗马音

``````print("mitsuha")
``````

# D

``````#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define lowbit(x) ((x)&(-(x)))
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define maxheap(x) priority_queue<x,vector<x>,less<x> >
#define minheap(x) priority_queue<x,vector<x>,greater<x> >
#define endl '\n'
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef long long ll;
typedef unsigned long long ull;
//#define mod 1000000009
//#define mod 1000000007
ll b[100005];
ll a[100005];
ll d[100005];
int main()
{
ll n,c;
cin>>n>>c;
int i;
for(i=1;i<=n;i++) cin>>b[i];
for(i=1;i<=n;i++) cin>>a[i];
for(i=1;i<=n;i++)
{
d[i]=abs(a[i]-b[i]);
}
ll l,r;
r=1;
l=1;
ll res=0;
ll sum=0;
for(r=1;r<=n;r++)
{
sum+=d[r];
while(sum>=c&&l<=r)
{
sum-=d[l];
l++;
}
res=max(res,r-l+1);
}
cout<<res;
return 0;
}
``````

# E

``````#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define lowbit(x) ((x)&(-(x)))
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define maxheap(x) priority_queue<x,vector<x>,less<x> >
#define minheap(x) priority_queue<x,vector<x>,greater<x> >
#define endl '\n'
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef long long ll;
typedef unsigned long long ull;
//#define mod 1000000009
//#define mod 1000000007
int b[100005];
int a[100005];
int main()
{
int t;
cin>>t;
while(t--)
{
int n,m,c;
cin>>n>>m>>c;
int i;
for(i=1;i<=n;i++) cin>>b[i];
for(i=1;i<=n;i++) cin>>a[i];
ll kuijiu,yali;
kuijiu=yali=0;
int flag=0;
for(i=1;i<=n;i++)
{
if(b[i]==1)
{
yali+=a[i];
}
else{
yali-=a[i];
kuijiu+=c;
}
if(yali>m||kuijiu>m)
{
flag=1;
break;
}
}
if(flag)
{
cout<<"YES"<<endl;
}
else cout<<"NO"<<endl;
}

return 0;
}
``````

# F

``````#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define lowbit(x) ((x)&(-(x)))
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define maxheap(x) priority_queue<x,vector<x>,less<x> >
#define minheap(x) priority_queue<x,vector<x>,greater<x> >
#define endl '\n'
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef long long ll;
typedef unsigned long long ull;
//#define mod 1000000009
//#define mod 1000000007
struct node
{
ll a,b,val;
bool operator<(node z)
{
if(val!=z.val)
{
return val<z.val;
}
else return a<z.a;
}
}d[200005];
int main()
{
int n,k;
cin>>n>>k;
int i;
for(i=1;i<=n;i++) cin>>d[i].a>>d[i].b;
for(i=1;i<=n;i++)
{
d[i].val=d[i].a^d[i].b;
}
sort(d+1,d+1+n);
ll res=0;
for(i=n;i>n-k;i--)
{
res+=d[i].a;
}
cout<<res;
return 0;
}
``````

# G

``````

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
// 定义结构体
struct Data {
std::string s;
int a, b;

// 构造函数
Data(std::string str, int num1, int num2)
{
s=str;
a=num1;
b=num2;
}
bool operator<(Data z)
{
if((a^b)!=(z.a^z.b)) return (a^b)>(z.a^z.b);
if(a!=z.a) return a>z.a;
if(b!=z.b) return b>z.b;
return s>z.s;
}
};

int main() {
int n;
std::cin >> n; // 读取输入的行数

std::vector<Data> data; // 创建一个结构体向量来存储数据

// 读取n行输入数据
while(n-- ) {
std::string s;
int a, b, len;
std::cin  >> s >> a >> b; // 读取字符串和两个整数
data.push_back((Data){s,a,b}); // 将数据添加到向量中
}

// 使用lambda表达式对向量进行排序
sort(data.begin(),data.end());

// 打印排序后的结果
for (const auto tmp : data) { // 使用结构化绑定
std::cout << tmp.s << " " << tmp.a << " " << tmp.b << std::endl;
}

return 0;
}
``````

3 收藏 评论