Fucked up

搞砸了。下次早点起来热身

Solving

  1. A. Game
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    for (int i = 0; i < t; i++){
        int p = -1;
        int q = -1;
        int n;
        cin >> n;
        int a[n];
        for (int j = 0; j < n; j++){
            cin >> a[j];
            if (a[j] == 1 && p == -1){
                p = j;
            }
            else if (a[j] == 0 && p != -1){
                if(q == -1) q = j - 1;
                p = -1;
            }
        }
        if (q == -1) q = 0;
        if (p - q == 1){
            cout << 0 << endl;
        }
        else{
            cout << p - q << endl;
        }
    }
}
  1. Game of Ball Passing
#include <bits/stdc++.h>
using namespace std;
bool cmp(long long x, long long y){
    return x > y;
}
int main(){
    long long t;
    cin >> t;
    for (long long i = 0; i < t; i++){
        long long n;
        cin >> n;
        long long a[n];
        long long cnt = 0;
        for (long long j = 0; j < n; j++) {
            cin >> a[j];
            cnt += a[j];
        }
        sort(a, a+n, cmp);
        // for (long long j = 0; j < n; j++) {
        //     cout << a[j] << endl;
        // }
        if (cnt == 0){
            cout << 0 << endl;
        }else{
            if (a[0] > cnt-a[0]){
                cout << a[0] - (cnt-a[0]) << endl;
            }
            else {
                cout << 1 << endl;
            }
        }
    }
}
  1. C. Weird Sum
    by simonmysun
#include <bits/stdc++.h>

using namespace std;

int t, n, m;

vector<long long> colorx[100005];
vector<long long> colory[100005];

int main() {
  // cin >> t;
  t = 1;
  while(t--) {
    cin >> n >> m;
    for(int i = 0; i < n; i += 1) {
      for(int j = 0; j < m; j += 1) {
        int color;
        cin >> color;
        colorx[color].push_back(i);
        colory[color].push_back(j);
      }
    }
    long long sum = 0;
    for(int i = 0; i < 100005; i += 1) {
      int l = colorx[i].size();
      long long r = 0;
      long long s = 0;
      sort(colorx[i].begin(), colorx[i].end());
      for(int j = 0; j < l; j += 1) {
        r += colorx[i][j] * j - s;
        s += colorx[i][j];
      }
      sum += r;
      r = 0;
      s = 0;
      sort(colory[i].begin(), colory[i].end());
      for(int j = 0; j < l; j += 1) {
        r += colory[i][j] * j - s;
        s += colory[i][j];
      }
      sum += r;
    }
    cout << sum << endl;
  }
  return 0;
}
  1. D
    to be continue ...

Summary

cheer my self up. Prepare for next round DIV.3
下轮好好打,DIV3, 233333333