Submission #955913

# Submission time Handle Problem Language Result Execution time Memory
955913 2024-03-31T17:18:59 Z lbm364dl Art Exhibition (JOI18_art) C++14
50 / 100
1000 ms 8280 KB
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <queue>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
#define show(x) cerr << #x" = " << (x) << "\n"
#else
#define show(x) 0
#endif

#define pb push_back
#define pp pop_back
#define mp make_pair
#define fst first
#define snd second
#define FOR(var, from, to) for(int var = from; var < int(to); ++var)
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.rend()
#define sz(x) int(x.size())
#define vec(x) vector<x>
#define INF 2000000000

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// use unique second element of pair to work as multiset
//typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
const ll mod = 1000000007, mod2 = 998244353;

template<typename T, typename U> ostream &operator<<(ostream &os, pair<T,U> p){os << "(" << p.fst << "," << p.snd << ")"; return os;}
template<typename T, typename U> istream &operator>>(istream &is, pair<T,U> &p){is >> p.fst >> p.snd; return is;}
template<typename T> istream &operator>>(istream &is, vector<T> &v){FOR(i, 0, v.size()) is >> v[i]; return is;}
template<typename T> ostream &operator<<(ostream &os, vector<T> v){for(T x : v) os << x << " "; return os;}
template<typename T> ostream &operator<<(ostream &os, set<T> s){for(T x : s) os << x << " "; return os;} 
template<typename T> ostream &operator<<(ostream &os, multiset<T> s){for(T x : s) os << x << " "; return os;} 
template<typename T, typename U> ostream &operator<<(ostream &os, map<T,U> m){for(auto x : m) os << x << " "; return os;} 
//ostream &operator<<(ostream &os, ordered_set s){for(int x : s) os << x << " "; return os;} 
//ostream &operator<<(ostream &os, ordered_multiset s){for(pii x : s) os << x.fst << " "; return os;} 
ll mod_pow(ll a, ll b, ll m){ ll sol = 1; while(b){ if(b&1){ sol = (sol*a)%m; b--; }else{ a = (a*a)%m; b/=2; } } return sol;}
ll rem(ll a, ll b){ ll res = a%b; return res < 0 ? res+b : res; }

void test_case(){
  int n; cin >> n;
  vector<pll> v(n); cin >> v;
  sort(all(v));
  ll mx = 0;
  FOR(i, 0, n){
    ll cur = 0;
    FOR(j, i, n){
      cur += v[j].snd;
      mx = max(mx, cur - (v[j].fst - v[i].fst));
    }
  }
  cout << mx << "\n";
}

int main(){
	#ifndef LOCAL
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
	#endif

  int t = 1;
	FOR(i, 0, t) test_case();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 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 1 ms 344 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 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 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 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 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 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 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 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 0 ms 348 KB Output is correct
27 Correct 13 ms 348 KB Output is correct
28 Correct 13 ms 344 KB Output is correct
29 Correct 14 ms 344 KB Output is correct
30 Correct 13 ms 344 KB Output is correct
31 Correct 13 ms 348 KB Output is correct
32 Correct 13 ms 348 KB Output is correct
33 Correct 13 ms 344 KB Output is correct
34 Correct 13 ms 344 KB Output is correct
35 Correct 13 ms 348 KB Output is correct
36 Correct 13 ms 348 KB Output is correct
37 Correct 13 ms 348 KB Output is correct
38 Correct 13 ms 344 KB Output is correct
39 Correct 13 ms 360 KB Output is correct
40 Correct 13 ms 536 KB Output is correct
41 Correct 13 ms 348 KB Output is correct
42 Correct 13 ms 348 KB Output is correct
43 Correct 13 ms 536 KB Output is correct
44 Correct 13 ms 540 KB Output is correct
45 Correct 13 ms 348 KB Output is correct
46 Correct 13 ms 348 KB Output is correct
47 Correct 13 ms 536 KB Output is correct
48 Correct 13 ms 348 KB Output is correct
49 Correct 13 ms 348 KB Output is correct
50 Correct 13 ms 348 KB Output is correct
51 Correct 13 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 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 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 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 0 ms 348 KB Output is correct
27 Correct 13 ms 348 KB Output is correct
28 Correct 13 ms 344 KB Output is correct
29 Correct 14 ms 344 KB Output is correct
30 Correct 13 ms 344 KB Output is correct
31 Correct 13 ms 348 KB Output is correct
32 Correct 13 ms 348 KB Output is correct
33 Correct 13 ms 344 KB Output is correct
34 Correct 13 ms 344 KB Output is correct
35 Correct 13 ms 348 KB Output is correct
36 Correct 13 ms 348 KB Output is correct
37 Correct 13 ms 348 KB Output is correct
38 Correct 13 ms 344 KB Output is correct
39 Correct 13 ms 360 KB Output is correct
40 Correct 13 ms 536 KB Output is correct
41 Correct 13 ms 348 KB Output is correct
42 Correct 13 ms 348 KB Output is correct
43 Correct 13 ms 536 KB Output is correct
44 Correct 13 ms 540 KB Output is correct
45 Correct 13 ms 348 KB Output is correct
46 Correct 13 ms 348 KB Output is correct
47 Correct 13 ms 536 KB Output is correct
48 Correct 13 ms 348 KB Output is correct
49 Correct 13 ms 348 KB Output is correct
50 Correct 13 ms 348 KB Output is correct
51 Correct 13 ms 348 KB Output is correct
52 Execution timed out 1090 ms 8280 KB Time limit exceeded
53 Halted 0 ms 0 KB -