Đăng nhập để hỏi chi tiết
Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
@$\text{JoonHae}$
Bài `6` DISTINCT
#include<bits/stdc++.h>
#define hutao long long
using namespace std;
hutao a[1000005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("DISTINCT.inp","r",stdin);
freopen("DISTINCT.out","w",stdout);
hutao n;
cin>>n;
for(hutao i=1;i<=n;i++)
{
cin>>a[i];
}
sort(a+1,a+1+n);
hutao dem=0;
for(hutao i=1;i<=n;i++)
{
if(a[i]!=a[i+1])
{
cout<<a[i]<<" ";
}
}
}
Bài `7` SMK
#include<bits/stdc++.h>
#define hutao long long
using namespace std;
hutao a[1000005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("SMK.inp","r",stdin);
freopen("SMK.out","w",stdout);
hutao n,k,ans=0,tong=0;
cin>>n;
for(hutao i=1;i<=n;i++)
{
cin>>a[i];
}
cin>>k;
for(hutao i=1;i<=k;i++)
{
tong+=a[i];
}
ans=tong;
for(hutao i=k+1;i<=n;i++)
{
tong+=a[i]-a[i-k];
ans=max(ans,tong);
}
cout<<ans;
return 0;
}
Bài `8` MISNUM
#include <bits/stdc++.h>
#define hutao long long
using namespace std;
hutao a[1000005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("MISNUM.inp","r",stdin);
freopen("MISNUM.out","w",stdout);
hutao n;
cin>>n;
map<hutao,bool> mp;
for(hutao i=1;i<=n;i++)
{
mp[i]=false;
}
for(hutao i=1;i<n;i++)
{
cin>>a[i];
mp[a[i]]=true;
}
for(pair<hutao,hutao>x:mp)
{
if(!x.second)
{
cout<<x.first;
return 0;
}
}
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin