wjhhsa

279

acwing_45764

wjhhsa
1天前
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int a[1005];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
cout<<(a[1]+a[2])/2<<' ';
for(int i=2;i<=n-1;i++){
cout<<(a[i-1]+a[i]+a[i+1])/3<<' ';
}
cout<<(a[n-1]+a[n])/2;
return 0;
}


wjhhsa
2天前
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5+5;
int a[N],q[10005],sum,maxm;
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i ++ ){
cin >>a[i];
if(a[i]>a[i-1]){
q[a[i-1]+1]++;
q[a[i]+1]--;
}
}
for (int i = 1; i <= 10004; i ++ ){
sum+=q[i];
maxm=max(maxm,sum);
}
cout << maxm;
return 0;
}


wjhhsa
2天前
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int arr[100006];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++){
int x;
cin>>x;
arr[i]=x;
}
sort(arr,arr+n);
if(n&1){
cout<<arr[n-1]<<' '<<arr[n/2]<<' '<<arr[0];
}
else {
cout<<arr[n-1]<<' ';
double t;
if((arr[n/2-1]+arr[n/2])%2!=0){
t=(arr[n/2-1]+arr[n/2])/2.0;
printf("%.1f",t);
}
else cout<<(arr[n/2-1]+arr[n/2])/2;
cout<<' ';
cout<<arr[0];
}
}


wjhhsa
2天前
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
int num,maxm;
vector<pair<int,int>> arr;
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++){
int x;
cin>>x;
int sum=0;
for(int j=1;j<=m;j++){
int y;
cin>>y;
y=-1*y;
x-=y;
sum+=y;
}
num+=x;
maxm=max(maxm,sum);
arr.push_back(make_pair(sum,i));
}
sort(arr.begin(),arr.end());
int j;
for(int i=0;i<arr.size();i++){
if(arr[i].first==maxm){
j=arr[i].second;
break;
}
}
cout<<num<<' '<<j<<' '<<maxm;
return 0;
}


wjhhsa
3天前
#include<bits/stdc++.h>
using namespace std;
bool a[1003];
int main()
{
int n,m;
cin >> n>>m;
vector<pair<int,int>> arr;
char s;
for (int i = 0; i < n; i ++ ){
int first,second;
cin>>first>>second;
arr.push_back(make_pair(first, second));
cin >> s;
if(s=='A') a[i]=true;
else a[i]=false;
}
int c,c1,c2;
for (int i=0;i<m;i++){
cin >> c>>c1>>c2;
int flag=1;
bool q[1003];
copy(begin(a),end(a),begin(q));
long long t,h;
t=arr[0].first,h=arr[0].second;
if(c+c1*t+c2*h>0){
if(!q[0]){
for (int j = 0; j <n; j++) {
q[j] = !q[j];
}
}
}
else{
if(q[0]){
for (int j = 0; j <n; j++) {
q [j] = !q[j];
}
}
}
for (int i = 0; i < n; i ++ ){
long long t,h;
t=arr[i].first,h=arr[i].second;
if(c+c1*t+c2*h>0){
if(q[i]==0) flag=0;
}
else{
if(q[i]==1) flag=0;
}
}
if(flag==1) cout <<"Yes"<<endl;
else if(flag==0) cout <<"No"<<endl;
}
return 0;
}


wjhhsa
4天前
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int flag[25],g[25];
int main()
{
int n,k,t,x1,y1,x2,y2;
cin >> n>>k>>t>>x1>>y1>>x2>>y2;
for (int i = 1; i <= n; i ++ ){
int cnt = 0;
for(int j=1;j<=t;j++){
int x,y;
cin >>x>>y;
if((x>=x1&&x<=x2)&&(y>=y1&&y<=y2)) {
flag[i]=1;
cnt++;
if(cnt >= k) {
g[i]=1;
}
}
else {
cnt = 0;
}
}
}
int sum=0,gm=0;
for(int i=1;i<=n;i++){
sum+=flag[i],gm+=g[i];
}
cout << sum<<endl<<gm;
return 0;
}


wjhhsa
4天前
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int n,x,y,a,b;
cin >> n>>a>>b;
int c[202];
for (int i = 0; i < n; i ++ ){
cin >> x>>y;
c[i]=(a-x)*(a-x)+(b-y)*(b-y);
}
vector<pair<int, int>> arr;
for (int i = 0; i <n; i++) {
arr.push_back(make_pair(c[i], i));
}
sort(arr.begin(),arr.end());
for (int i = 0; i <3; i ++ ){
cout << arr[i].second+1<<endl;
}
return 0;
}


wjhhsa
7天前
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


wjhhsa
1个月前
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


wjhhsa
1个月前
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~