Submission #686680

# Submission time Handle Problem Language Result Execution time Memory
686680 2023-01-25T18:38:01 Z thegamercoder19 Art Exhibition (JOI18_art) C++14
50 / 100
1000 ms 20664 KB
/*
Coded by thegamercoder19
GL
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846
#define FILER 0
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = pow(10, 9) + 7;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const ull INFUL = 0x3f3f3f3f3f3f3f3f;
const ll INFT = 0x3f3f3f3f;
const ull MAX = 1e5 + 1;
const ll MODD = 998244353;
const double EPS = 1e-10;
#define V vector
#define pll pair<ll, ll>
#define pull2 pair<ull,ull>
#define MS multiset
#define M map
#define Q queue
#define PQ priority_queue
#define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c)
#define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c)
#define FORA(a,i) for(auto &i : a)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define sorta(a) sort(all(a))
#define sortd(a) sort(all(a), greater<ll>())
#define setp(x) setprecision(x)<<fixed
#define RET return
#define log(a,b) log(b)/log(a)
#define WH(s) while(s)
#define WHI(t) WH(t--)
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define YESNO(s) cout << (s ? "YES" : "NO") << endl;
#define YesNo(s) cout<<(s?"Yes":"No")<<endl;
#define TYP 0
using namespace std;
ll n, res,s, ama, ami;
V<pll> a;
bool cmp(const pll & a, const pll & b)
{
    if (a.first == b.first)return a.second > b.second;
    return a.first < b.first;
}
void solve() {
    cin >> n;
    a.resize(n);
    FOR(ll, i, 0, n, 1)cin >> a[i].first >> a[i].second;
    sort(all(a), cmp);
    res = 0;
    FOR(ll, i, 0, n, 1)
    {
        ami = INFL, ama = 0, s = 0;
        FOR(ll, j, i, n, 1)
        {
            ami = min(ami, a[j].first), ama = max(ama, a[j].first), s += a[j].second;
            res = max(res, s - ama + ami);
        }
    }
    cout << res << endl;

}
void init()
{


}
void handle()
{
    init();
    ll t = 1;
    if (TYP)cin >> t;
    //getline(cin, s);
    WHI(t)solve();
}

int main()
{
    IOF
        handle();
    RET 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 288 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 288 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 35 ms 468 KB Output is correct
28 Correct 31 ms 468 KB Output is correct
29 Correct 32 ms 468 KB Output is correct
30 Correct 29 ms 456 KB Output is correct
31 Correct 29 ms 512 KB Output is correct
32 Correct 30 ms 468 KB Output is correct
33 Correct 31 ms 520 KB Output is correct
34 Correct 29 ms 468 KB Output is correct
35 Correct 33 ms 456 KB Output is correct
36 Correct 30 ms 580 KB Output is correct
37 Correct 30 ms 468 KB Output is correct
38 Correct 30 ms 468 KB Output is correct
39 Correct 29 ms 468 KB Output is correct
40 Correct 30 ms 468 KB Output is correct
41 Correct 37 ms 460 KB Output is correct
42 Correct 33 ms 468 KB Output is correct
43 Correct 31 ms 508 KB Output is correct
44 Correct 29 ms 468 KB Output is correct
45 Correct 29 ms 468 KB Output is correct
46 Correct 29 ms 468 KB Output is correct
47 Correct 31 ms 456 KB Output is correct
48 Correct 29 ms 468 KB Output is correct
49 Correct 31 ms 508 KB Output is correct
50 Correct 35 ms 468 KB Output is correct
51 Correct 30 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 288 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 35 ms 468 KB Output is correct
28 Correct 31 ms 468 KB Output is correct
29 Correct 32 ms 468 KB Output is correct
30 Correct 29 ms 456 KB Output is correct
31 Correct 29 ms 512 KB Output is correct
32 Correct 30 ms 468 KB Output is correct
33 Correct 31 ms 520 KB Output is correct
34 Correct 29 ms 468 KB Output is correct
35 Correct 33 ms 456 KB Output is correct
36 Correct 30 ms 580 KB Output is correct
37 Correct 30 ms 468 KB Output is correct
38 Correct 30 ms 468 KB Output is correct
39 Correct 29 ms 468 KB Output is correct
40 Correct 30 ms 468 KB Output is correct
41 Correct 37 ms 460 KB Output is correct
42 Correct 33 ms 468 KB Output is correct
43 Correct 31 ms 508 KB Output is correct
44 Correct 29 ms 468 KB Output is correct
45 Correct 29 ms 468 KB Output is correct
46 Correct 29 ms 468 KB Output is correct
47 Correct 31 ms 456 KB Output is correct
48 Correct 29 ms 468 KB Output is correct
49 Correct 31 ms 508 KB Output is correct
50 Correct 35 ms 468 KB Output is correct
51 Correct 30 ms 468 KB Output is correct
52 Execution timed out 1041 ms 20664 KB Time limit exceeded
53 Halted 0 ms 0 KB -