Submission #203293

# Submission time Handle Problem Language Result Execution time Memory
203293 2020-02-20T06:59:11 Z wendy_virgo Art Exhibition (JOI18_art) C++14
30 / 100
1000 ms 1120 KB
#include <bits/stdc++.h>

using namespace std;

#define taskname "JOI18_art"
#define forinc(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define fordec(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define foreach(i, x) for (auto &i : x)
#define ms(x, n) memset(x, n, sizeof(x))
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define fi first
#define se second
#define pb push_back
#define pf push_front

template<typename TH>
void _dbg(const char* sdbg, TH h)
{
	cerr << sdbg << " = " << h << "\n";
}

template<typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t)
{
	while (*sdbg != ',') cerr << *sdbg++;
	cerr << " = " << h << ",";
	_dbg(sdbg + 1, t...);
}

#define db(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define chkpt cerr << "--- Checkpoint here ---\n";

const int N=5e5+5;

int n;
int64_t a[N],b[N];
int p[N];
int64_t s[N];

bool Cmp(int x,int y)
{
    return a[x]<a[y];
}

void Sub3()
{
    int64_t ans=0;
    forinc(i,1,n)
    {
        p[i]=i;
    }
    sort(p+1,p+1+n,Cmp);
    map<int,int> l,r;
    forinc(i,1,n)
    {
        r[a[p[i]]]=i;
        s[i]=s[i-1]+b[p[i]];
    }
    fordec(i,n,1)
    {
        l[a[p[i]]]=i;
    }
    forinc(i,1,n)
    {
        forinc(j,i,n)
        {
            ans=max(ans,s[r[a[p[j]]]]-s[l[a[p[i]]]-1]-a[p[j]]+a[p[i]]);
        }
    }
    cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
//	freopen(taskname".INP","r",stdin);
	#endif // ONLINE_JUDGE
	cin>>n;
	forinc(i,1,n)
	{
	    cin>>a[i]>>b[i];
	}
	Sub3();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 388 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 388 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 9 ms 376 KB Output is correct
13 Correct 9 ms 376 KB Output is correct
14 Correct 8 ms 376 KB Output is correct
15 Correct 9 ms 376 KB Output is correct
16 Correct 9 ms 376 KB Output is correct
17 Correct 9 ms 380 KB Output is correct
18 Correct 9 ms 376 KB Output is correct
19 Correct 9 ms 504 KB Output is correct
20 Correct 9 ms 376 KB Output is correct
21 Correct 8 ms 376 KB Output is correct
22 Correct 8 ms 376 KB Output is correct
23 Correct 8 ms 376 KB Output is correct
24 Correct 9 ms 376 KB Output is correct
25 Correct 9 ms 376 KB Output is correct
26 Correct 8 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 388 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 9 ms 376 KB Output is correct
13 Correct 9 ms 376 KB Output is correct
14 Correct 8 ms 376 KB Output is correct
15 Correct 9 ms 376 KB Output is correct
16 Correct 9 ms 376 KB Output is correct
17 Correct 9 ms 380 KB Output is correct
18 Correct 9 ms 376 KB Output is correct
19 Correct 9 ms 504 KB Output is correct
20 Correct 9 ms 376 KB Output is correct
21 Correct 8 ms 376 KB Output is correct
22 Correct 8 ms 376 KB Output is correct
23 Correct 8 ms 376 KB Output is correct
24 Correct 9 ms 376 KB Output is correct
25 Correct 9 ms 376 KB Output is correct
26 Correct 8 ms 376 KB Output is correct
27 Execution timed out 1077 ms 1120 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 388 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 9 ms 376 KB Output is correct
13 Correct 9 ms 376 KB Output is correct
14 Correct 8 ms 376 KB Output is correct
15 Correct 9 ms 376 KB Output is correct
16 Correct 9 ms 376 KB Output is correct
17 Correct 9 ms 380 KB Output is correct
18 Correct 9 ms 376 KB Output is correct
19 Correct 9 ms 504 KB Output is correct
20 Correct 9 ms 376 KB Output is correct
21 Correct 8 ms 376 KB Output is correct
22 Correct 8 ms 376 KB Output is correct
23 Correct 8 ms 376 KB Output is correct
24 Correct 9 ms 376 KB Output is correct
25 Correct 9 ms 376 KB Output is correct
26 Correct 8 ms 376 KB Output is correct
27 Execution timed out 1077 ms 1120 KB Time limit exceeded
28 Halted 0 ms 0 KB -