-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc345_c.py
More file actions
105 lines (96 loc) · 2.13 KB
/
abc345_c.py
File metadata and controls
105 lines (96 loc) · 2.13 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
abc345_c.py
###############################################
[titia AC]
import sys
input = sys.stdin.readline
n=int(input())
L=[]
for i in range(n):
x,y=map(int,input().split())
L.append((x,-y,i+1))
L.sort()
MAX=[-1<<60]*(n+1)
for i in range(n-1,-1,-1):
MAX[i]=max(MAX[i+1],L[i][1])
D=set()
for i in range(n):
if L[i][1]<MAX[i+1]:
D.add(L[i][2])
ANS=set(range(1,n+1))-D
print(len(ANS))
print(*sorted(ANS))
###############################################
[shakayami AC]
N=int(input())
card=[]
for i in range(N):
a,c=map(int,input().split())
card.append((i,a,c))
card.sort(key=lambda x:-x[1])
ans=[]
minC=10**18
for i,a,c in card:
if c<minC:
ans.append(i+1)
minC=min(c,minC)
ans.sort()
print(len(ans))
print(*ans)
###############################################
[kotatsu cpp AC]
#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
using namespace std;
int A[2<<17],C[2<<17];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;cin>>N;
vector<int>id(N);
for(int i=0;i<N;i++)
{
cin>>A[i]>>C[i];
id[i]=i;
}
sort(id.begin(),id.end(),[](int i,int j){return A[i]>A[j];});
vector<int>ans;
int mn=2e9;
for(int i:id)
{
if(mn>C[i])mn=C[i],ans.push_back(i);
}
sort(ans.begin(),ans.end());
cout<<ans.size()<<"\n";
for(int v:ans)cout<<v+1<<" ";
cout<<endl;
}
###############################################
###############################################
###############################################
###############################################
###############################################
###############################################
###############################################
[my TLE14]
[強さでソートして、コストの逆転を拾い上げる]
[i,jで全ての組み合わせを調べるところが時間の無駄]
N=int(input())
A=[]
for i in range(N):
a,c=map(int,input().split())
A+=[[a,c,i+1]]
A2=sorted(A)[::-1]
#print(A2)
M=list(range(1,N+1))
DEL=[]
for i in range(N-1):
for j in range(i+1,N):
if A2[i][1]<A2[j][1]:
DEL+=[A2[j][2]]
ANS=set(M)-set(DEL)
print(len(ANS))
print(*list(ANS))
###############################################