Submission #127231

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