Submission #45838


ソースコード

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
37
38
39
40
41
42
//区間を理解する。
#include<iostream>
#include<cstdio>
#include<cstring>
int max(int a,int b);
int main(){
int n;
int pos[200010]; //ここ
int acc[200010]; //ここ
int l,r;
char type;
int i;
int m=0,ans=0;
memset(pos,0,sizeof(pos));
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %c",&l,&r,&type);
if(type=='+'){
pos[100000+l]++; //ここ
pos[100000+r+1]--; //ここ
}else if(type=='-'){
pos[100000+l]--; //ここ
pos[100000+r+1]++; //ここ
}
m=max(m,100000+r+1);
}
for(i=0;i<=m;i++){
acc[i]=acc[i-1]+pos[i];
ans=max(ans,acc[i]);
}
printf("%d\n",ans);
return 0;
}
int max(int a,int b){
if(a>b)
return a;
else
return b;
}

ステータス

項目 データ
問題 0974 - 場のポテンシャル
ユーザー名 ei1841
投稿日時 2018-12-13 15:36:45
言語 C++
状態 Accepted
得点 10
ソースコード長 773 Byte
最大実行時間 44 ms
最大メモリ使用量 2300 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input-sample01 AC 29 ms 1756 KB
1
input-sample02 AC 19 ms 2208 KB
1
input01 AC 32 ms 2036 KB
1
input02 AC 44 ms 2112 KB
1
input03 AC 31 ms 2060 KB
1
input04 AC 29 ms 2140 KB
1
input05 AC 21 ms 1956 KB
1
input06 AC 27 ms 2032 KB
1
input07 AC 32 ms 2116 KB
1
input08 AC 24 ms 2064 KB
1
input09 AC 29 ms 2144 KB
1
input10 AC 21 ms 2220 KB
1
input11 AC 22 ms 2172 KB
1
input12 AC 25 ms 2120 KB
1
input13 AC 28 ms 2072 KB
1
input14 AC 40 ms 2024 KB
1
input15 AC 38 ms 2224 KB
1
input16 AC 25 ms 2300 KB
1
input17 AC 36 ms 2252 KB
1
input18 AC 32 ms 2072 KB
1
input19 AC 34 ms 2276 KB
1
input20 AC 36 ms 2224 KB
1
input21 AC 36 ms 2172 KB
1
input22 AC 22 ms 1484 KB
1
input23 AC 21 ms 2208 KB
1