Submission #1502037


Source Code Expand

#include <bits/stdc++.h>

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct N001 {
   long n;
   std::vector<long> parents;
   std::vector<long> numbers;
   N001(long n_) : n(n_), parents(n+1, -1), numbers(n+1, -1) {
   }
};
long find(N001& s, long x) {
   if( s.parents[x] == -1 ) return x;
   return s.parents[x] = find(s, s.parents[x]);
}
bool same(N001& s, long x, long y) {
   return find(s, x) == find(s, y);
}
void unite(N001& s, long x, long y) {
   long x2 = find(s, x);
   long y2 = find(s, y);
   if( x2 == y2 ) return;
   if( not ( s.numbers[x2] <= s.numbers[y2] ) )
      std::swap(x2, y2);
   s.parents[x2] = y2;
   s.numbers[y2] += s.numbers[x2];
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long k, t; scan(k, t);
      LI ts(t); for(long &t2 : ts) scan(t2);
      std::sort(ts.begin(), ts.end());
      std::reverse(ts.begin(), ts.end());
      LI xs;
      for(long i = 0; i < t; ++i) {
         long x = ts[i];
         for(long m = 0; m < x; ++m) {
            xs.push_back(i);
         }
      }
      LI ys(k);
      long index = 0;
      for(long first : {0, 2, 1, 3}) {
         for(long i = first; i < k; i+=4) {
            ys[index] = xs[i];
            index += 1;
         }
      }
      for(long i = 0; i < k; ++i) {
         dumpll(i, ys[i]);
      }
      long res = 1;
      long temp = 1;
      for(long i = 1; i < k; ++i) {
         if( ys[i-1] == ys[i] ) {
            temp += 1;
            res = std::max(res, temp);
         }
         else {
            temp = 1;
         }
      }
      printf("%ld\n", res - 1);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}

Submission Info

Submission Time
Task B - K Cakes
User spica314
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3021 Byte
Status WA
Exec Time 1 ms
Memory 512 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 3
AC × 3
WA × 7
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt WA 1 ms 512 KB
1_004.txt WA 1 ms 256 KB
1_005.txt WA 1 ms 256 KB
1_006.txt WA 1 ms 256 KB
1_007.txt WA 1 ms 256 KB
1_008.txt WA 1 ms 256 KB
1_009.txt WA 1 ms 256 KB