HOC24
Lớp học
Môn học
Chủ đề / Chương
Bài học
#include<bits/stdc++.h>using namespace std;int main() { int n; cin>>n; int A[n],B[n],C[2*n]; for (int i=0; i<n;i++) { cin>>A[i]; } for (int i=0;i<n; i++) { cin>>B[i]; } for (int i=0;i<n;i++) { C[2*i]=A[i]; C[2*i+1]=B[i]; } for (int i=0; i<2*n;i++) { cout<<C[i]<< " "; }}
#include <iostream>using namespace std;
int main(){ int n, x; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int q; cin >> q; while (q--) { int cnt = 0; cin >> x; for (int i = 0; i < n; i++) if (a[i] == x) cnt++; cout << cnt << endl; } return 0;}
#include <bits/stdc++.h>using namespace std;long long n, a[100000], i, b[100000], s, j, k;int main(){ cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; } k = 2; b[1] = 0; for (i = 2; i <= n; i++) { for (j = 1; j <= i - 1; j++) { if (a[j] > a[i]) { s++; } } b[k] = s; k++; s = 0; } for (i = 1; i <= k - 1; i++) { cout << b[i] << " "; }}
#include<bits/stdc++.h>using namespace std;int main(){ int n; cin>>n; int a[n]; for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n); int cnt=0; for(int i=n-1;i>=0;i--) if(a[i]==a[n-1]) cnt++; cout<<cnt<<endl; return 0;}
#include <bits/stdc++.h>using namespace std;int main(){ long long n,a[1000001]; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } sort(a+1,a+n+1,greater<long long>()); for(int i=1;i<=n;i++) { cout<<a[i]<<" "; }}
int main() { int n; cin >> n; int t[n]; for (int i = 0; i < n; i++) { cin >> t[i]; } int a = 0; int b = 0; int i = 0; int j = n - 1; int ta = 0; int tb = 0; \ while (i <= j) { if (ta <= tb) { ta += t[i]; a++; i++; } else { tb += t[j]; b++; j--; } } cout << a << " " << b << endl; return 0;}
#include<bits/stdc++.h>using namespace std;long long a[1];int main(){ int n,t; long long s=0; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for (int i=1;i<=n;i++) s=s+a[i]; cout<<s;
}
#include<bits/stdc++.h>using namespace std;long long a[1000001],n,s,m;int main(){ cin>>n; s=0; m=0; for(int i=1;i<=n;i++) { cin>>a[i]; if(a[i]%2==0) s++; else m++; } cout<<s<<'\n'<<m;}
#include<iostream>using namespace std;int main() { int a,b; while(cin>>a>>b) { if(a>b) cout << "YES"<<endl; else cout<<"NO"<<endl; } }
#include<iostream>using namespace std;int main() { int a,b; while(cin>>a>>b) { int s=abs(a-b); cout << s << endl; } }