Submission #37834

# Submission time Handle Problem Language Result Execution time Memory
37834 2017-12-28T08:40:44 Z mirbek01 Divide and conquer (IZhO14_divide) C++14
48 / 100
1000 ms 37172 KB
# include <bits/stdc++.h>

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e6 + 5;

typedef long long ll;

int n, a[N];
ll ans, b[N], c[N], cb[N], cc[N], s1, s2;

int main()
{
      cin >> n;

      for(int i = 1; i <= n; i ++)
      {
            cin >> a[i] >> b[i] >> c[i];
            cb[i] = b[i];
            cc[i] = c[i];
            b[i] += b[i - 1];
            c[i] += c[i - 1];
      }

      for(int i = 1; i <= n; i ++)
            c[i] -= a[i];

      for(int i = 1; i <= n; i ++)
      {
//            cout << "\\\\\\\\\\\\\\\\\\\n";
            for(int j = i; j <= n; j ++)
            {
                  ll res = b[j] - s1, sum = c[j] - s2;
//                  cout << sum + a[i] << " " << a[j] << " " << i << " " << j << endl;
                  if(sum + a[i] < 0) continue;
                  ans = max(ans, res);
            }
            s1 += cb[i];
            s2 += cc[i];
//            for(int j = i; j <= n; j ++)
//                  b[j] -= cb[i], c[j] -= cc[i];
      }

      cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 37172 KB Output is correct
2 Correct 0 ms 37172 KB Output is correct
3 Correct 0 ms 37172 KB Output is correct
4 Correct 0 ms 37172 KB Output is correct
5 Correct 0 ms 37172 KB Output is correct
6 Correct 0 ms 37172 KB Output is correct
7 Correct 0 ms 37172 KB Output is correct
8 Correct 0 ms 37172 KB Output is correct
9 Correct 0 ms 37172 KB Output is correct
10 Correct 0 ms 37172 KB Output is correct
11 Correct 0 ms 37172 KB Output is correct
12 Correct 0 ms 37172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 37172 KB Output is correct
2 Correct 0 ms 37172 KB Output is correct
3 Correct 0 ms 37172 KB Output is correct
4 Correct 0 ms 37172 KB Output is correct
5 Correct 0 ms 37172 KB Output is correct
6 Correct 3 ms 37172 KB Output is correct
7 Correct 0 ms 37172 KB Output is correct
8 Correct 0 ms 37172 KB Output is correct
9 Correct 3 ms 37172 KB Output is correct
10 Correct 3 ms 37172 KB Output is correct
11 Correct 16 ms 37172 KB Output is correct
12 Correct 16 ms 37172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 37172 KB Output is correct
2 Correct 103 ms 37172 KB Output is correct
3 Correct 96 ms 37172 KB Output is correct
4 Execution timed out 1000 ms 37172 KB Execution timed out
5 Halted 0 ms 0 KB -