Submission #285768

#TimeUsernameProblemLanguageResultExecution timeMemory
285768limabeansElection Campaign (JOI15_election_campaign)C++17
0 / 100
57 ms5876 KiB
#include <bits/stdc++.h> using namespace std; template<typename T> void out(T x) { cout << x << endl; exit(0); } #define watch(x) cout << (#x) << " is " << (x) << endl using ll = long long; const ll mod = 1e9+7; const int maxn = 1e5 + 5; int n, x[maxn], y[maxn]; int m; int a[maxn], b[maxn], c[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for (int i=0; i<n-1; i++) { cin>>x[i]>>y[i]; } cin>>m; for (int i=0; i<m; i++) { cin>>a[i]>>b[i]>>c[i]; } // assume subtask 2 vector<pair<int,int>> v; for (int i=0; i<m; i++) { v.push_back({b[i],a[i]}); } int hi = -1; int res = 0; sort(v.begin(),v.end()); for (auto p: v) { int l = p.second; int r = p.first; if (l>hi) { res++; hi = max(hi, r); } } cout<<res<<endl; return 0; }
#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...