Submission #565273

#TimeUsernameProblemLanguageResultExecution timeMemory
565273SSRSElection Campaign (JOI15_election_campaign)C++14
5 / 100
163 ms6664 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<vector<int>> E(N); for (int i = 0; i < N - 1; i++){ int X, Y; cin >> X >> Y; } int M; cin >> M; vector<int> A(M), B(M); for (int i = 0; i < M; i++){ int C; cin >> A[i] >> B[i] >> C; if (A[i] > B[i]){ swap(A[i], B[i]); } A[i]--; } vector<pair<int, int>> P(M); for (int i = 0; i < M; i++){ P[i] = make_pair(B[i], A[i]); } sort(P.begin(), P.end()); int p = -1; int ans = 0; for (int i = 0; i < M; i++){ if (P[i].second >= p){ p = P[i].first; ans++; } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...