Codeforces Round #672 (Div. 2)
Codeforces Round #672 (Div. 2)
A. Cubes Sorting
#include <bits/stdc++.h>
//#define int ll
using namespace std;
#pragma GCC optimize(2)
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 10;
void solve() {
int n;
cin>>n;
int a,flag=1;
cin>>a;
for (int i = 1; i < n; ++i) {
int b;
cin>>b;
if (a<=b) flag=0;
a=b;
}
cout<<(flag?"NO":"YES")<<endl;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}
B. Rock and Lever
#include <bits/stdc++.h>
//#define int ll
using namespace std;
//#pragma GCC optimize(2)
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 10;
ll b[50];
void solve() {
ll n,a;
cin>>n;
memset(b,0,sizeof(b));
for (int i = 0; i <n; ++i) {
cin>>a;
int temp=0;
while (a) temp++,a/=2;
b[temp]++;
}
ll sum=0;
for (int i = 1; i < 50; ++i) sum+=b[i]*(b[i]-1)/2;
cout<<sum<<"\n";
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}
C1. Pokémon Army (easy version)
#include <bits/stdc++.h>
//#define int ll
using namespace std;
//#pragma GCC optimize(2)
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 3e5 + 10;
int a[maxn],b[maxn];
void solve() {
int n,q;
ll sum=0;
cin>>n>>q;
for (int i = 1; i <= n; ++i) cin>>a[i];
a[n+1]=0;
for (int i = 1; i <=n; ++i) {
b[i]=a[i]-a[i-1];
if (b[i]>0) sum+=b[i];
}
cout<<sum<<"\n";
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}
相關文章
- 【CodeForces】 Codeforces Round #672 (Div. 2) B.Rock and Lever (思維&位運算)
- Codeforces Round #639 (Div. 2)
- Codeforces Round #541 (Div. 2)
- Codeforces Round #682 (Div. 2)
- Codeforces Round #678 (Div. 2)
- Codeforces Round #747 (Div. 2)
- Codeforces Round #673 (Div. 2)
- Codeforces Round #448 (Div. 2) A
- Codeforces Round #217 (Div. 2)
- Codeforces Round #256 (Div. 2)
- Codeforces Round #259 (Div. 2)
- Codeforces Round #257 (Div. 2)
- Codeforces Round #258 (Div. 2)
- Codeforces Round #171 (Div. 2)
- Codeforces Round #173 (Div. 2)
- Codeforces Round 951 (Div. 2)
- Codeforces Round 955 (Div. 2)
- Codeforces Round 953 (Div. 2)
- Codeforces Round 975 (Div. 2)
- Codeforces Round 976 (Div. 2)
- Codeforces Round 972 (Div. 2)
- Codeforces Round 979 (Div. 2)
- Codeforces Round 982 (Div. 2)
- Codeforces Round 932 (Div. 2)
- Codeforces Round 934 (Div. 2)
- Codeforces Round 940 (Div. 2)
- Codeforces Round 973 (Div. 2)
- Codeforces Round 960 (Div. 2)
- Codeforces Round 958 (Div. 2)
- Codeforces Round 961 (Div. 2)
- Codeforces Round 948 (Div. 2)
- Codeforces Round 945 (Div. 2)
- Codeforces Round 873 (Div. 2)
- Codeforces Round 969 (Div. 2)
- Codeforces Round 949 (Div. 2)
- Codeforces Round 965 (Div. 2)
- Codeforces Round 963 (Div. 2)
- Codeforces Round 967 (Div. 2)