6092 | 2023-10-29 18:04:16 | Ignác | Zsonglőrködés | cpp11 | Time limit exceeded 0/100 | 1.6s | 7040 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<pair<long long, long long>> a(N);
for(int i = 0; i < N - 1; i++){
cin >> a[i].first >> a[i].second;
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
for(int i = N-1; i >= 0; i--){
for(int j = i-1; j >= 0; j--){
if(a[i].second == a[j].first){
a[i].second = a[j].second;
a.erase(a.begin() + j);
break;
}
}
}
cout << a.size();
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1812 KiB | ||||
2 | Accepted | 3ms | 2052 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Accepted | 4ms | 2120 KiB | ||||
4 | Accepted | 1.057s | 4172 KiB | ||||
5 | Time limit exceeded | 1.57s | 4408 KiB | ||||
6 | Time limit exceeded | 1.578s | 5044 KiB | ||||
7 | Time limit exceeded | 1.578s | 5268 KiB | ||||
8 | Time limit exceeded | 1.575s | 5532 KiB | ||||
9 | Time limit exceeded | 1.577s | 5856 KiB | ||||
10 | Time limit exceeded | 1.565s | 5608 KiB | ||||
11 | Time limit exceeded | 1.582s | 5740 KiB | ||||
subtask3 | 0/35 | ||||||
12 | Accepted | 3ms | 3640 KiB | ||||
13 | Accepted | 3ms | 3352 KiB | ||||
14 | Accepted | 3ms | 3356 KiB | ||||
15 | Wrong answer | 3ms | 3484 KiB | ||||
16 | Accepted | 4ms | 3732 KiB | ||||
17 | Accepted | 4ms | 3804 KiB | ||||
18 | Accepted | 3ms | 3872 KiB | ||||
19 | Accepted | 3ms | 3948 KiB | ||||
20 | Wrong answer | 3ms | 3952 KiB | ||||
subtask4 | 0/45 | ||||||
21 | Accepted | 4ms | 4292 KiB | ||||
22 | Time limit exceeded | 1.6s | 4284 KiB | ||||
23 | Time limit exceeded | 1.532s | 5692 KiB | ||||
24 | Time limit exceeded | 1.6s | 6140 KiB | ||||
25 | Time limit exceeded | 1.565s | 6444 KiB | ||||
26 | Time limit exceeded | 1.557s | 6720 KiB | ||||
27 | Time limit exceeded | 1.529s | 7008 KiB | ||||
28 | Time limit exceeded | 1.562s | 7040 KiB | ||||
29 | Time limit exceeded | 1.56s | 7032 KiB |