Submission #166383

# Submission time Handle Problem Language Result Execution time Memory
166383 2019-12-02T03:14:49 Z abil Divide and conquer (IZhO14_divide) C++17
17 / 100
6 ms 504 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
#define int long long

using namespace std;

const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (1e15 + 9);

int x[N], g[N], c[N];
main()
{
	int n;
	scanf("%lld", &n);
	for(int i = 1;i <= n; i++){
		scanf("%lld%lld%lld", &x[i], &g[i], &c[i]);
	}
	int ans = 0, last = -INF, sum = 0;
	for(int i = 1;i <= n; i++){
		if(x[i] - c[i] <= last){
			sum += g[i];
		}
		else{
			sum = g[i];
		}
			last = x[i] + c[i];
		ans = max(ans, sum);
	}
	cout << ans;
}

Compilation message

divide.cpp:17:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
divide.cpp: In function 'int main()':
divide.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
divide.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", &x[i], &g[i], &c[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -