Submission #127233

# Submission time Handle Problem Language Result Execution time Memory
127233 2019-07-09T07:15:51 Z nhimnam120 Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
#pragma optimize(O3)
#define fi first
#define se second
using namespace std;
set<long long> inp;
map<long long, long long> val;
vector<pair<long long, long long> > pro;
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n;
	cin >> n;
	for(int i=1;i<=n;i++){
		long long a,b;
		cin >> a >> b;
		val[a]+=b;
		inp.insert(a);
	}
	for(auto x: inp){
		pro.push_back({x,val[x]});
	}
	long long mdx=INT_MIN;
	long long max_end_here=0;
	long long MAX=INT_MIN,MIN=INT_MAX;
	long long sum=0;
	for(int i=0;i<pro.size();i++){
		if(MAX<pro[i].fi){
			MAX=pro[i].fi;
		}
		if(MIN>pro[i].fi){
			MIN=pro[i].fi;
		}
		sum+=pro[i].se;
		max_end_here=sum - (MAX-MIN);
		if(max_end_here>mdx){
			mdx=max_end_here;
		}
		if(max_end_here<0){
			max_end_here=0;
			MAX=INT_MIN;
			MIN=INT_MAX;
			sum=0;
		}
	}
	cout << mdx;
}

Compilation message

art.cpp:2:0: warning: ignoring #pragma optimize  [-Wunknown-pragmas]
 #pragma optimize(O3)
 
art.cpp: In function 'int main()':
art.cpp:27:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<pro.size();i++){
              ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -