Submission #00008


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<bits/stdc++.h>
using namespace std;
//#inclde<bits/extc++.h>
//using namespace __gnu_pbds;
//template<class A>using Set=tree<A, null_type,less<A>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
#define ai (*i)
#define fi first
#define se second
#define ff first.first
#define ss second.second
#define mp(f,s) make_pair(f.s)
#define vs(a) sort(a.begin(),a.end())
#define int long long
signed main(){
int n,l,a,b,z=0,x=0,y=0;
cin>>n>>l;
vector<pair<int,int>> v(n);
for(int i=0;i<n;++i){
cin>>a>>b;
v[i]=make_pair(a,(b?-1:1));
}
sort(v.begin(),v.end());
for(int i=0;i<n;++i){
x+=(v[i].fi-y-1)*v[i].se;
z=max(z,x);
++y;
}
reverse(v.begin(),v.end());
for(int i=0;i<n;++i){
x+=(l-y)*-v[i].se;
z=max(z,x);
}
cout<<z<<'\n';
return 0;
}

ステータス

項目 データ
問題 0007 - 矢印
ユーザー名 捻正
投稿日時 2021-09-09 17:28:48
言語 C++17
状態 Accepted
得点 10
ソースコード長 847 Byte
最大実行時間 53 ms
最大メモリ使用量 2076 KB

セット

セット 得点 Cases
1 ALL 10 / 10 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1 AC 20 ms 604 KB
1
in2 AC 18 ms 676 KB
1
in3 AC 26 ms 436 KB
1
in4 AC 22 ms 612 KB
1
in5 AC 24 ms 456 KB
1
in6 AC 24 ms 428 KB
1
in7 AC 21 ms 528 KB
1
in8 AC 15 ms 496 KB
1
in9 AC 25 ms 596 KB
1
in10 AC 16 ms 580 KB
1
in11 AC 21 ms 556 KB
1
in12 AC 18 ms 532 KB
1
in13 AC 22 ms 376 KB
1
in14 AC 20 ms 596 KB
1
in15 AC 15 ms 572 KB
1
in16 AC 20 ms 540 KB
1
in17 AC 18 ms 504 KB
1
in18 AC 22 ms 604 KB
1
in19 AC 20 ms 576 KB
1
in20 AC 23 ms 652 KB
1
in21 AC 21 ms 620 KB
1
in22 AC 26 ms 592 KB
1
in23 AC 19 ms 692 KB
1
in24 AC 20 ms 536 KB
1
in25 AC 21 ms 504 KB
1
in26 AC 19 ms 476 KB
1
in27 AC 18 ms 708 KB
1
in28 AC 22 ms 804 KB
1
in29 AC 24 ms 756 KB
1
in30 AC 53 ms 2076 KB
1