Submission #124529

# Submission time Handle Problem Language Result Execution time Memory
124529 2019-07-03T13:26:12 Z johutha Orchard (NOI14_orchard) C++14
13 / 25
278 ms 15992 KB
#include <iostream>
#include <vector>

#define int int64_t

using namespace std;

struct orchard
{
    vector<vector<int>> orchard;

    int n, m;

    int calc()
    {
        for (int i = 0; i < n; i++)
        {
            int currsum = 0;
            int mmin = 0;
            int mp = -1;
            int mdiff = 0;
            int msp = 0;
            int me = 0;
            for (int j = 0; j < m; j++)
            {
                currsum += (orchard[i][j]) - (!orchard[i][j]);
                if (currsum < mmin)
                {
                    mmin = currsum;
                    mp = j;
                }
                if (currsum - mmin > mdiff)
                {
                    msp = mp;
                    mdiff = currsum - mmin;
                    me = j;
                }
            }
            currsum = 0;
            for (int j = 0; j < m; j++)
            {
                if (j <= msp || j > me) currsum += (orchard[i][j]);
                else currsum += (!orchard[i][j]);
            }
            return currsum;
        }
    }
};

signed main()
{
    int n, m;
    cin >> n >> m;
    orchard orch;
    orch.n = n;
    orch.m = m;
    orch.orchard.resize(n, vector<int>(m));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> orch.orchard[i][j];
        }
    }
    cout << orch.calc() << "\n";
}

Compilation message

orchard.cpp: In member function 'int64_t orchard::calc()':
orchard.cpp:47:5: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 269 ms 15992 KB Output is correct
2 Correct 278 ms 15992 KB Output is correct
3 Correct 269 ms 15992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 186 ms 6276 KB Output isn't correct
2 Halted 0 ms 0 KB -