Submission #51311

# Submission time Handle Problem Language Result Execution time Memory
51311 2018-06-17T12:45:32 Z KieranHorgan Orchard (NOI14_orchard) C++17
8 / 25
1000 ms 8428 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define ll long long
#define int long long
#define ld long double
#define pii pair<int,int>
#define rand() abs((rand()<<15)|rand())
#define randll() abs(((long long)rand()<<30)|rand())

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);

  int n, m;
  cin >> n >> m;

  if(n == 1) {
    vector<int> grid(m+1, 0);
    int totalOnes = 0;
    for(int i = 1; i <= m; i++) {
      cin >> grid[i];
      if(grid[i]) {
        totalOnes++;
      }
    }
    for(int i = 1; i <= m; i++)
      grid[i] += grid[i-1];

    int ans = 1ll<<29;
    for(int i = 1; i <= m; i++) {
      for(int j = i; j <= m; j++) {
        int sz = j+1-i;
        int ins = grid[j]-grid[i-1];
        int cur = 0;
        cur += sz-ins;
        cur += totalOnes-ins;
        ans = min(ans, cur);
      }
    }
    cout << ans << endl;
  } else {

  }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 768 KB Output is correct
2 Correct 162 ms 768 KB Output is correct
3 Correct 163 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 8428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8428 KB Output isn't correct
2 Halted 0 ms 0 KB -