Submission #504997

#TimeUsernameProblemLanguageResultExecution timeMemory
504997Andy__Andy__Art Exhibition (JOI18_art)C++17
50 / 100
1066 ms24588 KiB
#include <bits/stdc++.h> #define ll long long #define int ll using namespace std; ifstream f ("test.in"); ofstream g ("test.out"); pair < int ,int > v[500005]; int sum[500005]; main() { int n,k; cin>>n; for(int i=1;i<=n;++i) { int valoare ,marime; cin>>marime >> valoare; v[i]={marime,valoare}; } sort(v+1,v+1+n); for(int i=1;i<=n;++i) sum[i] = sum[i-1] + v[i].second; int ans = 0; for(int i=1;i<=n;++i) { for(int j=i;j<=n;++j) { int tmp = sum[j] - sum[i-1] - v[j].first + v[i].first; ans = max(ans, tmp); } } cout<<ans; return 0; }

Compilation message (stderr)

art.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main()
      | ^~~~
art.cpp: In function 'int main()':
art.cpp:14:11: warning: unused variable 'k' [-Wunused-variable]
   14 |     int n,k;
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...