# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1112039 | 2024-11-13T14:43:12 Z | vjudge1 | Art Exhibition (JOI18_art) | C++ | 0 ms | 0 KB |
#include <iostream> #include <algorithm> #include <vector> using namespace std; int N; vector<long long int> SizeA={}; vector<long long int> PriceB={}; long long int findS(long long int Amin,long long int Amax){ long long int sum=0; for(__SIZE_TYPE__ i=0;i<SizeA.size();i++){ if(SizeA.at(i)>=Amin && SizeA.at(i)<=Amax) { sum+=PriceB.at(i); } } return sum; } int main() { cin >> N; long long int temp,Max=LLONG_MIN; for(int i=0;i<N;i++) { cin >> temp; SizeA.push_back(temp); cin >> temp; PriceB.push_back(temp); } for(__SIZE_TYPE__ i=0;i<SizeA.size()-1;i++){ for(__SIZE_TYPE__ j=i+1;j<SizeA.size();j++){ //cout << i << " " << j << " S is " << findS(min(SizeA.at(i),SizeA.at(j)),max(SizeA.at(i),SizeA.at(j)))<< endl; temp=findS(min(SizeA.at(i),SizeA.at(j)),max(SizeA.at(i),SizeA.at(j)))-abs(SizeA.at(i)-SizeA.at(j)); if(Max<temp){ Max=temp; //cout << "New max found "<<Max<<" i is "<<i<<" pointing to "<<SizeA.at(i)<<" j is "<<j<<" pointing to "<<SizeA.at(j)<<" and S is "<<temp<< endl; } } } cout << Max; return 0; }