Submission #710842

#TimeUsernameProblemLanguageResultExecution timeMemory
710842Jovan26Art Exhibition (JOI18_art)C++14
50 / 100
1027 ms49808 KiB
#include<bits/stdc++.h> using namespace std; int main(){ #define int long long int n; cin>>n; int a1[n]; int b[n]; map<int, int> mapa; for(int i=0;i<n;i++){ cin>>a1[i]>>b[i]; mapa[a1[i]]+=b[i]; } sort(a1,a1+n); vector<int> a; for(int i=0;i<n;i++){ if(i==0 || a1[i]!=a1[i-1]) a.push_back(a1[i]); } //int o = 0; int dp[a.size()]; dp[0] = mapa[a[0]]; int o = dp[0]; for(int i=1;i<a.size();i++){ //if(i!=0 && a[i]==a[i-1]) continue; dp[i] = max(dp[i-1]-a[i]+a[i-1]+mapa[a[i]], mapa[a[i]]); o = max(o, dp[i]); } //cout<<dp[1].second<<endl; cout<<o<<endl; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:23:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=1;i<a.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...