前言
D调死我了,累死了Orz
传送门 :
A.
首尾扫一遍,判断中间水的位置
MyCode
const int N = 110;
void solve()
{
int n;cin>>n;
vector<int> a;
for(int i=0;i<n;i++){
int x;cin>>x;
a.pb(x);
}
int res = 0 ;
for(int i=0;i<n;i++)
{
if(a[i])res++;
else break;
}
cout<<res<<endl;
res = min(res-1,n);
cout<<n-res<<endl;
}
B.
一个人两球 balbala 猜结论
Mycode
const int N = 1e5+10;
int n,a[N];
ll sum;
void solve()
{
cin>>n;
int maxn = -1;
sum = 0 ;
for(int i = 1;i<=n;i++){
int x;cin>>x;
sum+=x;
maxn = max(maxn,x);
}
if(!maxn){
cout<<0<<endl;
return;
}
if(1ll*2*maxn - 1 <= sum){
cout<<1<<endl;
return;
}
cout<<1ll*2*maxn - sum<<endl;
}
C.
分两个vector 然后偏移量计算
MyCode
const int N = 1e5+10;
vector<int> R[N],C[N];
int ans;
int n,m;
void init(){
for(int i=1;i<=N;i++){
R[i].clear();
C[i].clear();
}
ans = 0 ;
}
void solve()
{
cin>>n>>m;
init();
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
int x;cin>>x;
R[x].pb(i);
C[x].pb(j);
}
}
for(int i = 0 ;i<N; i++){
sort(all(R[i]));sort(all(C[i]));
if(R[i].size()){
int cnt = 0 , pre = 0 ,res = 0 ;
for(auto x : R[i]){
res += (x*cnt) - pre;
++cnt;
pre += x;
}
ans += res;
}
if(C[i].size()){
int cnt= 0 , pre = 0 ,res = 0 ;
for(auto x : C[i]){
res += (x*cnt) - pre;
++cnt;
pre +=x;
}
ans += res;
}
}
cout<<ans<<endl;
}
D.
balabal
Mycode
// Problem: D. Integral Array
// Contest: Codeforces - Codeforces Round #775 (Div. 2, based on Moscow Open Olympiad in Informatics)
// URL: https://codeforces.com/contest/1649/problem/D
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
//��һ�δ��Ϻ�վ֮�� ��Ϊʹ��#define int long long TLE���¿��˺ܾõ�ʱ�� ���˼���ģ��
//����ʹ�ø��ӵ�ģ��
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <queue>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define IOS ios::sync_with_stdio(false);
#define CIT cin.tie(0);
#define COT cout.tie(0);
#define int long long
#define ll long long
#define x first
#define y second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),x.end()
typedef priority_queue<int,vector<int>,greater<int>> Pri_m;
typedef pair<int,int> pii;
typedef vector<int> VI;
unordered_map<int,int> mp;
const int N = 1e6+110;
int a[N],n,c,t[N],temp;
inline void init(){
mp.clear();
for(int i = 0;i<=c;i++)
t[i] = 0 ;
// memset(t,0,sizeof t);
temp = 0 ;
}
inline void solve()
{
cin>>n>>c;
init();
for(int i=1;i<=n;i++){
cin>>a[i];
mp[a[i]] = 1;
}
if(mp[1] == 0 ){
cout<<"No"<<endl;
return;
}
for(int i=1;i<=c;i++){
for(int j = i;j<=c/i;j++){
if(mp[i] == 0 && mp[j] == 1)
if(t[i*j] < j) t[i*j] = j;
if(mp[j] == 0 && mp[i] == 1)
if(t[i*j] < i) t[i*j] = i;
// if( (mp[i]|mp[j] ) && g[i*j] <)
}
}
for(int i=1;i<=c;i++){
temp = max(temp,t[i]);
if(temp && mp[i]){
cout<<"No"<<endl;
return;
}
temp = max(0ll,temp-1);
}
cout<<"Yes"<<endl;
}
/**mYHeart is my algorithm**/
signed main()
{
IOS
CIT
COT
int t;cin>>t;while(t -- )
solve();
return 0;
}