Submission #42471

# Submission time Handle Problem Language Result Execution time Memory
42471 2018-02-27T15:17:06 Z MatheusLealV Divide and conquer (IZhO14_divide) C++14
48 / 100
1000 ms 4284 KB
#include <bits/stdc++.h>
#define N 100050
#define f first
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

typedef tuple <int, int, int> trip;

ll n, sum[N], g[N], x[N], E[N], dp[N], ans;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin>>n;

	for(int i = 1, a, b, c; i <= n; i++)
	{
		cin>>x[i]>>g[i]>>E[i];

		sum[i] = E[i] + sum[i - 1];

		g[i] += g[i - 1];
	}

	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= i; j++)
		{
			if(sum[i] - sum[j - 1] >= x[i] - x[j])
			{
				ans = max(ans, g[i] - g[j - 1]);
			}
		}
	}

	cout<<ans<<"\n";
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:18:17: warning: unused variable 'a' [-Wunused-variable]
  for(int i = 1, a, b, c; i <= n; i++)
                 ^
divide.cpp:18:20: warning: unused variable 'b' [-Wunused-variable]
  for(int i = 1, a, b, c; i <= n; i++)
                    ^
divide.cpp:18:23: warning: unused variable 'c' [-Wunused-variable]
  for(int i = 1, a, b, c; i <= n; i++)
                       ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 1 ms 676 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 684 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 1 ms 780 KB Output is correct
12 Correct 2 ms 780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 780 KB Output is correct
2 Correct 2 ms 780 KB Output is correct
3 Correct 2 ms 780 KB Output is correct
4 Correct 2 ms 780 KB Output is correct
5 Correct 3 ms 780 KB Output is correct
6 Correct 3 ms 796 KB Output is correct
7 Correct 3 ms 832 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 3 ms 904 KB Output is correct
10 Correct 4 ms 1064 KB Output is correct
11 Correct 15 ms 1228 KB Output is correct
12 Correct 14 ms 1376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1464 KB Output is correct
2 Correct 111 ms 1656 KB Output is correct
3 Correct 87 ms 1944 KB Output is correct
4 Execution timed out 1074 ms 4284 KB Time limit exceeded
5 Halted 0 ms 0 KB -