Submission #1049743

#TimeUsernameProblemLanguageResultExecution timeMemory
1049743vjudge1Art Exhibition (JOI18_art)C++17
30 / 100
1037 ms432 KiB
#pragma GCC optimize("O3") #pragma GCC target("avx2") #include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <cstdlib> #include <time.h> #include <queue> #include <set> #include <map> #include <string> #include <unordered_map> #include <unordered_set> #include <bits/stdc++.h> #define speed ios_base::sync_with_stdio(0), cin.tie(0) #define TxtIO freopen("points.in","r",stdin); freopen("points.out","w",stdout); using namespace std; const int mod = 998244353; #define ll long long const int N=2e5+5; //mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll binpow (ll a, ll n) { ll res = 1; while (n) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } void fcn(){ ll n; cin>>n; pair <ll,ll> a[n+3]; for (int i=0; i<n; i++){ cin>>a[i].first>>a[i].second; } sort(a,a+n); ll ans=0; for (int l=0; l<n; l++){ for (int r=n-1; r>=l; r--){ ll res=0; for (int i=l; i<=r; i++){ res+=a[i].second; } res-=(-a[l].first+a[r].first); ans=max(ans,res); } } cout<<ans; } int main(){ //srand(time(0)); //fflush(stdout); // freopen("bridges.in","r",stdin); freopen("bridges.out","w",stdout); // speed; ll T=1; // cin>>T; for (int i=1; i<=T; i++){ fcn(); } } /* 1 2 3 4 5 6 7 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...