답안 #708043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708043 2023-03-10T21:12:04 Z MODDI Art Exhibition (JOI18_art) C++14
50 / 100
1000 ms 20828 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
#define se second
#define fi first
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
ll set_on(int n, int k){
	return (n |= 1 << k);
}
ll set_off(int n, int k){
	return (n &= ~(1UL << k));
}
bool check_bit(int n, int k){
	int bit = (n >> k) & 1U;
	if(bit == 1)
		return true;
	return false;
}
void solve(){
	int n;
	cin>>n;
	vector<pair<ll, ll> > arr;
	for(int i = 0; i < n; i++){
		ll a, b;
		cin>>a>>b;
		arr.pb(mp(a,b));
	}
	sort(arr.begin(), arr.end());
	ll ans = 0;
	for(int i = 0; i < n; i++){
		ll sum = 0, big = 0, small = 1e17;
		for(int j = i; j < n; j++){
			sum += arr[j].se;
			big = max(big, arr[j].fi);
			small = min(small, arr[j].fi);
//			debug(i, j, sum, big, small);
			ans = max(ans, sum - big + small);
		}
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	startTime = clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 0 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 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 0 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 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 0 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 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 23 ms 596 KB Output is correct
28 Correct 23 ms 576 KB Output is correct
29 Correct 23 ms 596 KB Output is correct
30 Correct 23 ms 648 KB Output is correct
31 Correct 23 ms 596 KB Output is correct
32 Correct 23 ms 596 KB Output is correct
33 Correct 24 ms 576 KB Output is correct
34 Correct 23 ms 596 KB Output is correct
35 Correct 22 ms 596 KB Output is correct
36 Correct 22 ms 644 KB Output is correct
37 Correct 22 ms 576 KB Output is correct
38 Correct 23 ms 644 KB Output is correct
39 Correct 23 ms 648 KB Output is correct
40 Correct 22 ms 652 KB Output is correct
41 Correct 23 ms 596 KB Output is correct
42 Correct 22 ms 596 KB Output is correct
43 Correct 22 ms 668 KB Output is correct
44 Correct 22 ms 596 KB Output is correct
45 Correct 23 ms 596 KB Output is correct
46 Correct 22 ms 596 KB Output is correct
47 Correct 23 ms 648 KB Output is correct
48 Correct 23 ms 640 KB Output is correct
49 Correct 23 ms 636 KB Output is correct
50 Correct 23 ms 596 KB Output is correct
51 Correct 23 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 0 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 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 23 ms 596 KB Output is correct
28 Correct 23 ms 576 KB Output is correct
29 Correct 23 ms 596 KB Output is correct
30 Correct 23 ms 648 KB Output is correct
31 Correct 23 ms 596 KB Output is correct
32 Correct 23 ms 596 KB Output is correct
33 Correct 24 ms 576 KB Output is correct
34 Correct 23 ms 596 KB Output is correct
35 Correct 22 ms 596 KB Output is correct
36 Correct 22 ms 644 KB Output is correct
37 Correct 22 ms 576 KB Output is correct
38 Correct 23 ms 644 KB Output is correct
39 Correct 23 ms 648 KB Output is correct
40 Correct 22 ms 652 KB Output is correct
41 Correct 23 ms 596 KB Output is correct
42 Correct 22 ms 596 KB Output is correct
43 Correct 22 ms 668 KB Output is correct
44 Correct 22 ms 596 KB Output is correct
45 Correct 23 ms 596 KB Output is correct
46 Correct 22 ms 596 KB Output is correct
47 Correct 23 ms 648 KB Output is correct
48 Correct 23 ms 640 KB Output is correct
49 Correct 23 ms 636 KB Output is correct
50 Correct 23 ms 596 KB Output is correct
51 Correct 23 ms 596 KB Output is correct
52 Execution timed out 1056 ms 20828 KB Time limit exceeded
53 Halted 0 ms 0 KB -