# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66829 | 2018-08-12T11:39:56 Z | ege_eksi | Art Exhibition (JOI18_art) | C++14 | 2 ms | 252 KB |
#include<iostream> #include<cstdio> #include<cstdlib> #include<climits> #include<algorithm> using namespace std; bool mycomp(pair<long long int,int> x , pair<long long int,int> y) { if(x.first < y.first) { return 1; } else { return 0; } } int main() { int n; scanf("%d",&n); pair<long long int,int> *a = new pair<long long int,int>[n]; for(int i = 0 ; i < n ; i++) { scanf("%lli %d" , &a[i].first , &a[i].second); } sort(a , a+n , mycomp); pair<long long int , long int> *d = new pair<long long int , long int>[n]; int cnt = 0; d[0] = a[0]; for(int i = 1 ; i < n ; i++) { if(d[cnt].first != a[i].first) { cnt++; d[cnt] = a[i]; } else { d[cnt].second += a[i].second; } } long long int *prefix = new long long int[cnt]; prefix[0] = d[0].second; for(int i = 1 ; i <= cnt ; i++) { prefix[i] = prefix[i-1] + d[i].second; } long long int ans = INT_MIN; for(int i = 0 ; i <= cnt ; i++) { for(int j = i+1 ; j <= cnt ; j++) { long long int value; if(i == 0) { value = prefix[j]; } else { value = prefix[j] - prefix[i-1]; } ans = max(ans , value - (d[j].first - d[i].first)); } } printf("%d",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |