Submission #880755

# Submission time Handle Problem Language Result Execution time Memory
880755 2023-11-30T02:06:42 Z ReLice Art Exhibition (JOI18_art) C++14
100 / 100
150 ms 25268 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
//#define sz size()
#define bc back()
#define ar array
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool flag=false;
    if(x>y){
        x=y;flag|=true;
    }
    return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool flag=false;
    if (x<y){
        x=y;flag|=true;
    }
    return flag;
}
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e18+7;
const ll mod=998244353;
const ll N=2e5+7;
const ld eps=1e-9;

void solve(){
	ll i;
	ll n,m;
	ll a,b;
	cin>>n;
	deque<pair<ll,ll>> v(n);
	for(i=0;i<n;i++) cin>>v[i].fr>>v[i].sc;
	sort(all(v));
	v.pf({0,0});
	ll pref[n+5];
	pref[0]=0;
	for(i=1;i<=n;i++)
        pref[i]=pref[i-1]+v[i].sc;
	for(i=1;i<=n;i++)
        pref[i]=pref[i]-v[i].fr+v[1].fr;
    ll ans=0,mn=inf;
    for(i=1;i<=n;i++){
        ans=max(ans,v[i].sc);
        ans=max(ans,pref[i]);
        ans=max(ans,pref[i]-mn);
        mn=min(mn,pref[i]-(v[i+1].fr-v[i].fr));
    }
    cout<<ans<<endl;
}
signed main(){
	start();
    ll t=1;
	//cin>>t;
    while(t--) solve();
    return 0;
}
/*







*/

Compilation message

art.cpp: In function 'void solve()':
art.cpp:54:7: warning: unused variable 'm' [-Wunused-variable]
   54 |  ll n,m;
      |       ^
art.cpp:55:5: warning: unused variable 'a' [-Wunused-variable]
   55 |  ll a,b;
      |     ^
art.cpp:55:7: warning: unused variable 'b' [-Wunused-variable]
   55 |  ll a,b;
      |       ^
art.cpp: In function 'void fre(std::string)':
art.cpp:41:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:41:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 456 KB Output is correct
22 Correct 0 ms 464 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 456 KB Output is correct
22 Correct 0 ms 464 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 668 KB Output is correct
29 Correct 2 ms 600 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 604 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 2 ms 612 KB Output is correct
38 Correct 2 ms 612 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 612 KB Output is correct
42 Correct 2 ms 612 KB Output is correct
43 Correct 2 ms 472 KB Output is correct
44 Correct 2 ms 612 KB Output is correct
45 Correct 2 ms 612 KB Output is correct
46 Correct 2 ms 612 KB Output is correct
47 Correct 2 ms 612 KB Output is correct
48 Correct 2 ms 656 KB Output is correct
49 Correct 2 ms 612 KB Output is correct
50 Correct 2 ms 468 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 456 KB Output is correct
22 Correct 0 ms 464 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 668 KB Output is correct
29 Correct 2 ms 600 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 604 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 2 ms 612 KB Output is correct
38 Correct 2 ms 612 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 612 KB Output is correct
42 Correct 2 ms 612 KB Output is correct
43 Correct 2 ms 472 KB Output is correct
44 Correct 2 ms 612 KB Output is correct
45 Correct 2 ms 612 KB Output is correct
46 Correct 2 ms 612 KB Output is correct
47 Correct 2 ms 612 KB Output is correct
48 Correct 2 ms 656 KB Output is correct
49 Correct 2 ms 612 KB Output is correct
50 Correct 2 ms 468 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 142 ms 25124 KB Output is correct
53 Correct 140 ms 25168 KB Output is correct
54 Correct 141 ms 25124 KB Output is correct
55 Correct 141 ms 25168 KB Output is correct
56 Correct 143 ms 24992 KB Output is correct
57 Correct 140 ms 25148 KB Output is correct
58 Correct 142 ms 25012 KB Output is correct
59 Correct 143 ms 25268 KB Output is correct
60 Correct 140 ms 25112 KB Output is correct
61 Correct 141 ms 24992 KB Output is correct
62 Correct 138 ms 25168 KB Output is correct
63 Correct 141 ms 25108 KB Output is correct
64 Correct 141 ms 25016 KB Output is correct
65 Correct 150 ms 25116 KB Output is correct
66 Correct 148 ms 24996 KB Output is correct
67 Correct 145 ms 25168 KB Output is correct
68 Correct 144 ms 24992 KB Output is correct