Submission #1040373

# Submission time Handle Problem Language Result Execution time Memory
1040373 2024-08-01T02:39:36 Z vjudge1 Divide and conquer (IZhO14_divide) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	long long a[n+1],b[n+1],c[n+1],d[n+1],f[n+1],g[n+1];
	for(int i=0;i<n;i++)
	{
	    cin >> a[i+1] >> b[i+1] >> c[i+1];
	}
	a[0]=0;b[0]=0;c[0]=a[1]-a[0];d[0]=c[0];g[0]=0;f[0]=c[0];
	for(int i=1;i<=n;i++)
	{
	    g[i]=g[i-1]+b[i];
	    d[i]=c[i]+d[i-1];
	    if(i<n) f[i]=d[i]-a[i+1];
	    else f[i]=d[i]-a[i];
	}
	vector<pair<long long,int> > v;
	for(int i=0;i<=n;i++)
	{
	    v.push_back({f[i],i});
	}
	sort(v.begin(),v.end());/*
	for(int i=0;i<=n;i++)
	{
	    cout << v[i].first << ' ' << v[i].second << '\n';
	}/**/
	int mn=100000000;
	long long res=0;
	for(int i=0;i<=n;i++)
	{
	    if(v[i].second==0) continue;
	    mn=min(mn,v[i].second);
	    res=max(res,g[v[i].second]-g[mn-1]);
	}
	cout << res;
	return 0;
}

Compilation message

divide.cpp:30:3: warning: "/*" within comment [-Wcomment]
   30 |  }/**/
      |
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -