LOADING

加载过慢请开启缓存,浏览器默认开启

Waiting for the dawn

daily 2

2023/8/30

daily codeforces

阅读全文

daily 1

2023/8/29

CF 1667B

struct fenwick {
  ll PartialSum[MAXN];
  fenwick() {
    for (int i = 0; i < MAXN; i++) PartialSum[i] = 0;
  }
  inline void add(ll index, ll increase) {
    while (index < MAXN) {
      PartialSum[index] = max(increase, PartialSum[index]);
      index += index & -index;
    }
  }
  inline ll get(int index) {
    ll sum = -INF;
    while (index) {
      sum = max(sum, PartialSum[index]);
      index -= index & -index;
    }
    return sum;
  }
};
ll a[MAXN], ord[MAXN], dp[MAXN], sum[MAXN];
void solve() {
  int T;
  cin >> T;
  int n;
  fenwick tr;
  while (T--) {
   cin >> n;
   vector<pii> pre;
   for (int i = 1; i <= n; ++i) {
     tr.PartialSum[i] = -INF;
   }
   for (int i = 1; i <= n; ++i) {
     cin >> a[i];
     sum[i] = sum[i - 1] + a[i];
     pre.push_back({sum[i], -i});
   }
   sort(pre.begin(), pre.end());
   for (int i = 1; i <= n; ++i) {
     ord[-pre[i - 1].second] = i;
   }
   for (int i = 1; i <= n; ++i) {
     dp[i] = dp[i - 1] + (a[i] > 0 ? 1 : (a[i] < 0 ? -1 : 0));
     auto pp = tr.get(ord[i]);
     dp[i] = max(dp[i], tr.get(ord[i]) + i);
     if (sum[i] > 0) dp[i] = i;
     tr.add(ord[i], dp[i] - i);
   }
   cout << dp[n] << '\n';
   dp[0] = sum[0] = 0;
  } 
  return ;
}
阅读全文

daily 2

2023/8/29
阅读全文

daily 1

2023/8/28

CF 900C

struct fenwick {
  ll PartialSum[MAXN];
  fenwick() {
    for (int i = 0; i < MAXN; i++) PartialSum[i] = 0;
  }
  inline void add(ll index, ll increase) {
    while (index < MAXN) {
      PartialSum[index] += increase;
      index += index & -index;
    }
  }
  inline ll get(int index) {
    ll sum = 0;
    while (index) {
      sum += PartialSum[index];
      index -= index & -index;
    }
    return sum;
  }
};
void solve() {
  int n;
  cin >> n;
  vector<int> p(n + 1);
  fenwick tr;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  ll ans = -1, ans_i = 1;
  int cur_max = -1;
  vector<int> cnt(n + 1);
  for (int i = 1; i <= n; ++i) {
    cur_max = max(cur_max, p[i]);
    int cur_num = tr.get(p[i]);
    if (cur_num == i - 2) {
      cnt[cur_max]++;
    } else if (cur_num == i - 1){
      cnt[cur_max]--;
    }
    tr.add(p[i], 1);
  }
  for (int i = 1; i <= n; ++i) {
    if (cnt[i] > ans) {
      ans = cnt[i];
      ans_i = i;
    }
  }
  cout << ans_i << '\n';
  return;
}
阅读全文

daily 1

2023/8/27

CF 49A

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    bool flag=false;                
    while((ch=getchar())!=EOF)
    {
        if(ch=='A'||ch=='a'||ch=='E'||ch=='e'||ch=='I'||ch=='i'||ch=='O'||ch=='o'||ch=='U'||ch=='u'||ch=='V'||ch=='v'||ch=='Y'||ch=='y')
            flag=true;
        else if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z'))
            flag=false;
    }
    if(flag)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}
阅读全文

daily 1

2023/8/26

CF 46A

#include<iostream>
using namespace std;
int main(){
    int n,I=1,a[100];
    cin>>n;
    for(int i=1;i<=n-1;i++){
        I=I+i;
        if(I>n)
            I=I-n;
        a[i]=I;
    }
    for(int i=1;i<=n-1;i++)
        cout<<a[i]<<' ';
}
阅读全文

daily 2

2023/8/25

CF 1065C

struct fenwick {
  ll PartialSum[MAXN];
  fenwick() {
    for (int i = 0; i < MAXN; i++) PartialSum[i] = 0;
  }
  inline void add(ll index, ll increase) {
    while (index < MAXN) {
      PartialSum[index] += increase;
      index += index & -index;
    }
  }
  inline ll get(int index) {
    ll sum = 0;
    while (index) {
      sum += PartialSum[index];
      index -= index & -index;
    }
    return sum;
  }
};
void solve() {
  int n, k, ans = 0;
  cin >> n >> k;
  fenwick tr;
  vector<int> h(n + 1);
  int maxx = INT_MIN, minx = INT_MAX;
  for (int i = 1; i <= n; ++i) {
    cin >> h[i];
    maxx = max(maxx, h[i]);
    minx = min(minx, h[i]);
    tr.add(1, 1);
    tr.add(h[i] + 1, -1);
  } 
  if (maxx == minx) {
    cout << 0 << '\n';
    return;
  }
  ll sum = 0;
  bool flag = true;
  for (int i = maxx; i >= minx; --i) {
    auto cur = tr.get(i); //how many shits is greater or equal than height i
    if (cur + sum > k) {
      ans++;
      sum = cur;
      flag = false;
    } else {// other wise one shot to make them equal
      sum += cur;
      flag = true;
    }
  }
  if (flag) {
    ++ans;
  }
  cout << ans << '\n';
  return ;
}
阅读全文

daily 2

2023/8/24

daily codeforces

阅读全文

daily 2

2023/8/23

daily codeforces

阅读全文

daily 2

2023/8/22

daily codeforces

阅读全文
1 ... 9 10 11 12 13 ... 30
avatar
Yanxin Xiang

愿有一天能和你最重要的人再次相逢