Submission #959211

#TimeUsernameProblemLanguageResultExecution timeMemory
959211AbitoArranging Tickets (JOI17_arranging_tickets)C++17
0 / 100
1 ms4440 KiB
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define ppb pop_back #define ep insert #define endl '\n' #define elif else if #define pow pwr #define sqrt sqrtt #define int long long #define ll long long typedef unsigned long long ull; using namespace std; const int N=2e5+5; int a[N],b[N],n,m,f[N]; bool inv[N]; int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n>>m; int ans=n; for (int i=1;i<=m;i++){ cin>>a[i]>>b[i]; a[i]--; b[i]-=2; int c;cin>>c; if (a[i]>b[i]) swap(a[i],b[i]); for (int j=a[i];j<=b[i];j++) f[j]++; } while (true){ int idx=0,best=INT_MAX,mx=0; for (int i=0;i<n;i++) mx=max(mx,f[i]); for (int i=1;i<=m;i++){ if (inv[i]) continue; for (int j=a[i];j<=b[i];j++) f[j]--; for (int j=0;j<n;j++) if (j<a[i] || j>b[i]) f[j]++; int mxx=0; for (int j=0;j<n;j++) mxx=max(mxx,f[j]); if (mxx<mx && b[i]-a[i]+1<best) best=b[i]-a[i]+1,idx=i; for (int j=a[i];j<=b[i];j++) f[j]++; for (int j=0;j<n;j++) if (j<a[i] || j>b[i]) f[j]--; } if (!idx) break; inv[idx]=1; for (int j=a[idx];j<=b[idx];j++) f[j]--; for (int j=0;j<n;j++) if (j<a[idx] || j>b[idx]) f[j]++; } sort(f,f+n); cout<<f[n-1]<<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...