답안 #319357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
319357 2020-11-05T02:11:31 Z TAOwoosh Art Exhibition (JOI18_art) C++17
100 / 100
279 ms 21108 KB
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
#pragma GCC optimize ("trapv")
 
 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
#define rep(i, a, b) for(lli i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (lli)(x).size()
#define what_is(x) cerr << #x << " is " << x << endl;
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;
 
typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
 
#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout <<  *it  << " : " << a << endl;
    err(++it, args...);
}
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T, class compare>
using ordered_set = tree<T, null_type, compare, rb_tree_tag, tree_order_statistics_node_update>;
//usage: ordered_set< el tipo , el comparador> nombre;


int main(){
	fastio;
	lli n; scanf("%lld\n",&n);
	vii v(n);
	rep(i,0,n){
		lli a,b;
		scanf("%lld %lld\n",&a,&b);
		v[i]={a,b};
	}
	sort(all(v));
	lli ans=0,sum=0,maxi=0,mini=0;
	rep(i,0,n){
		if(v[i].ss>sum+v[i].ss-(max(maxi,v[i].ff)-mini)){
			ans=max(ans,v[i].ss);
			maxi=mini=v[i].ff;
			sum=v[i].ss;
		}else{
			maxi=max(maxi,v[i].ff);
			sum+=v[i].ss;
			ans=max(ans,sum-(maxi-mini));
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |  lli n; scanf("%lld\n",&n);
      |         ~~~~~^~~~~~~~~~~~~
art.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   50 |   scanf("%lld %lld\n",&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 404 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 368 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 404 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 368 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 404 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 368 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 492 KB Output is correct
30 Correct 3 ms 492 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 3 ms 492 KB Output is correct
33 Correct 3 ms 492 KB Output is correct
34 Correct 3 ms 492 KB Output is correct
35 Correct 4 ms 492 KB Output is correct
36 Correct 4 ms 512 KB Output is correct
37 Correct 3 ms 492 KB Output is correct
38 Correct 3 ms 492 KB Output is correct
39 Correct 3 ms 492 KB Output is correct
40 Correct 3 ms 492 KB Output is correct
41 Correct 3 ms 492 KB Output is correct
42 Correct 3 ms 492 KB Output is correct
43 Correct 3 ms 492 KB Output is correct
44 Correct 3 ms 492 KB Output is correct
45 Correct 3 ms 492 KB Output is correct
46 Correct 3 ms 492 KB Output is correct
47 Correct 3 ms 492 KB Output is correct
48 Correct 3 ms 492 KB Output is correct
49 Correct 4 ms 492 KB Output is correct
50 Correct 3 ms 492 KB Output is correct
51 Correct 3 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 404 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 368 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 492 KB Output is correct
30 Correct 3 ms 492 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 3 ms 492 KB Output is correct
33 Correct 3 ms 492 KB Output is correct
34 Correct 3 ms 492 KB Output is correct
35 Correct 4 ms 492 KB Output is correct
36 Correct 4 ms 512 KB Output is correct
37 Correct 3 ms 492 KB Output is correct
38 Correct 3 ms 492 KB Output is correct
39 Correct 3 ms 492 KB Output is correct
40 Correct 3 ms 492 KB Output is correct
41 Correct 3 ms 492 KB Output is correct
42 Correct 3 ms 492 KB Output is correct
43 Correct 3 ms 492 KB Output is correct
44 Correct 3 ms 492 KB Output is correct
45 Correct 3 ms 492 KB Output is correct
46 Correct 3 ms 492 KB Output is correct
47 Correct 3 ms 492 KB Output is correct
48 Correct 3 ms 492 KB Output is correct
49 Correct 4 ms 492 KB Output is correct
50 Correct 3 ms 492 KB Output is correct
51 Correct 3 ms 492 KB Output is correct
52 Correct 250 ms 20836 KB Output is correct
53 Correct 248 ms 21092 KB Output is correct
54 Correct 244 ms 21108 KB Output is correct
55 Correct 248 ms 21092 KB Output is correct
56 Correct 242 ms 20996 KB Output is correct
57 Correct 244 ms 20836 KB Output is correct
58 Correct 243 ms 20964 KB Output is correct
59 Correct 260 ms 21092 KB Output is correct
60 Correct 243 ms 21088 KB Output is correct
61 Correct 247 ms 20964 KB Output is correct
62 Correct 279 ms 20840 KB Output is correct
63 Correct 242 ms 20836 KB Output is correct
64 Correct 247 ms 20964 KB Output is correct
65 Correct 250 ms 20836 KB Output is correct
66 Correct 246 ms 20964 KB Output is correct
67 Correct 245 ms 20968 KB Output is correct
68 Correct 244 ms 21092 KB Output is correct