Submission #127234

#TimeUsernameProblemLanguageResultExecution timeMemory
127234nhimnam120Art Exhibition (JOI18_art)C++14
0 / 100
2 ms376 KiB
#include<bits/stdc++.h> #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 (stderr)

art.cpp: In function 'int main()':
art.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<pro.size();i++){
              ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...