Submission #972255

#TimeUsernameProblemLanguageResultExecution timeMemory
972255vjudge1Art Exhibition (JOI18_art)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include <sstream> using namespace std; #define accepted ios_base::sync_with_stdio(false);cin.tie(nullptr); #define Daulbekov signed #define Makan main #define int long long #define double long double #define pb push_back #define pf push_front #define F first #define S second const int N=1e5+7; const int MAX=9e18+7; const int INF=1e18; Daulbekov Makan(){ int n; cin>>n; pair<int,int>a[n]; int vozmozhno=0; for(int i=0;i<n;i++){ cin>>a[i].F>>a[i].S; vozmozhno=max(vozmozhno,a[i].S); } sort(a,a+n); int mx=a[0].S,col=a[0].S; bool b=1; for(int i=1;i<n;i++){ if(b==0){ b=1; col+=a[i].S; mx=max(mx,col); continue; } col+=a[i].S; col-=(a[i].F-a[i-1].F); if(col<0){ col=0; b=0; } mx=max(mx,col); } cout<<max(mx,vozmozhno); } // 2 3 // 4 5 // 11 2
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...