Submission #1829347
Source Code Expand
#include<bits/stdc++.h> #define pb push_back using namespace std; typedef long long int ll; typedef unsigned long long int ull; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout<<setprecision(6); cout<<fixed; #ifdef DEBUG freopen("ip.txt","r",stdin); clock_t tStart = clock(); #endif ll n,c,ans=0; cin>>n>>c; vector< pair<ll,ll> > v; vector< pair< pair<ll,ll>, int> > rec; for(int i=0;i<n;++i) {int st,fin,ch; cin>>st>>fin>>ch; rec.pb({{st,fin},ch});} sort(rec.begin(),rec.end()); for(ll j=0;j<n;++j){ int st=rec[j].first.first,fin=rec[j].first.second,ch=rec[j].second; bool found=false; for(int i=0;i<v.size() && !found;++i){ if(v[i].second==ch){ if(v[i].first<=st) {v[i].first=fin; found=true;} } else{ if(v[i].first<=st-1) {found=true; v[i].first=fin; v[i].second=ch;} } } if(!found) {v.pb({fin,ch}); ans++;} //for(int i=0;i<v.size();++i) cout<<i+1<<" "<<v[i].first<<" "<<v[i].second<<endl; } cout<<ans<<'\n'; #ifdef DEBUG cout<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)<<"s.\n"; #endif return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Recording |
User | madhur4127 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1154 Byte |
Status | AC |
Exec Time | 35 ms |
Memory | 4980 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 35 ms | 4572 KB |
02.txt | AC | 34 ms | 4084 KB |
03.txt | AC | 34 ms | 4212 KB |
04.txt | AC | 35 ms | 3444 KB |
05.txt | AC | 31 ms | 4340 KB |
06.txt | AC | 17 ms | 1912 KB |
07.txt | AC | 12 ms | 1912 KB |
08.txt | AC | 2 ms | 256 KB |
09.txt | AC | 34 ms | 3444 KB |
10.txt | AC | 33 ms | 4980 KB |
11.txt | AC | 34 ms | 3444 KB |
12.txt | AC | 1 ms | 256 KB |
13.txt | AC | 1 ms | 256 KB |
14.txt | AC | 1 ms | 256 KB |
15.txt | AC | 1 ms | 256 KB |
16.txt | AC | 34 ms | 3444 KB |
17.txt | AC | 33 ms | 3444 KB |
18.txt | AC | 34 ms | 4084 KB |
19.txt | AC | 34 ms | 3444 KB |
sample_01.txt | AC | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 1 ms | 256 KB |