# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
44133 |
2018-03-30T08:04:23 Z |
wasyl |
Orchard (NOI14_orchard) |
C++11 |
|
19 ms |
16832 KB |
#include <bits/stdc++.h>
#ifndef dbg
#define dbg(...)
#endif
#define all(x) begin(x), end(x)
#define rsz(...) resize(__VA_ARGS__)
#define psh(...) push_back(__VA_ARGS__)
#define emp(...) emplace_back(__VA_ARGS__)
#define prt(...) print(cout, __VA_ARGS__)
#define dmp(...) print(cerr, #__VA_ARGS__, '=', __VA_ARGS__)
#define dprt(...) dbg(print(cerr,__VA_ARGS__))
#define ddmp(...) dbg(dmp(__VA_ARGS__))
using namespace std;using ll=long long;
template<typename t>using V=vector<t>;
template<typename t>void print(ostream& os, const t& a){os<<a<<'\n';}
template<typename t, typename... A>void print
(ostream& os, const t& a, A&&... b){os<<a<<' ';print(os, b...);}
int n, m;
V< V< int > > tb;
inline int spr (V< int >& ilo)
{
int sum = 0;
int res = 0;
for (int i = 0; i < m; ++i)
{
sum += ilo[i];
if (sum < 0)
sum = 0;
res = max(res, sum);
}
return res;
}
inline int spr (int lo, int hi)
{
V< int > ilo;
for (int k = 0; k < m; ++k)
ilo.psh(tb[hi][k] - tb[lo - 1][k]);
dbg(
dmp(lo, hi);
for (int& i : ilo)
cerr << i << ' ';
cerr << '\n';
)
return spr(ilo);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
tb.rsz(n + 1, V< int >(m));
int sum = 0;
for (int i = 1; i <= n; ++i)
{
string s; cin >> s;
for (int k = 0; k < m; ++k)
{
tb[i][k] = s[k] - '0';
sum += tb[i][k];
tb[i][k] = tb[i][k] == 1? 1 : -1;
}
}
ddmp(sum);
for (int k = 0; k < m; ++k)
for (int i = 1; i <= n; ++i)
tb[i][k] += tb[i - 1][k];
int res = INT_MAX;
for (int i = 1; i <= n; ++i)
for (int k = i; k <= n; ++k)
res = min(res, sum - spr(i, k));
prt(res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
1260 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
19 ms |
16832 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
16832 KB |
Execution killed with signal 7 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
16832 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
16832 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |