Submission #344627

# Submission time Handle Problem Language Result Execution time Memory
344627 2021-01-06T06:43:57 Z Erzhan06 Divide and conquer (IZhO14_divide) C++14
0 / 100
1000 ms 620 KB
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define bananas return 0;
#define ll long long
#define IOS ios_base :: sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
const int N=2e5+6;
const int INF=1e9+6;
int main() {
freopen("divide.in", "r", stdin);
freopen("divide.out", "w", stdout);
IOS
	ll n;
	cin>>n;
	int x[n+1],g[n+1],e[n+1];
	for (int i=1;i<=n;i++) {
		cin>>x[i]>>g[i]>>e[i];
	}
	ll mx=-1;
	for(int i=1;i<=n;i++) {
		ll energy=0;
		ll point=0;
		ll gold=0;
		ll distanse=x[i];
		for (int j=i;j<=n;j++) {
			energy+=e[j];
			point+=x[j]-distanse;
			distanse=x[j];
			if (energy>=point) {
				gold+=g[j];
				mx=max(gold,mx);
			}else {
				break;
			}
		}
	}
	cout<<mx;
bananas
 
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:15:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   15 | freopen("divide.in", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
divide.cpp:16:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   16 | freopen("divide.out", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 620 KB Time limit exceeded
2 Halted 0 ms 0 KB -