Submission #300529

#TimeUsernameProblemLanguageResultExecution timeMemory
300529DovranCarnival Tickets (IOI20_tickets)C++17
11 / 100
2 ms768 KiB
#include <bits/stdc++.h> #include "tickets.h" #define N 2009 #define ll long long #define pii pair<ll, ll> #define ff first #define ss second #define sz() size() #define pb push_back #define pp() pop_back() using namespace std; ll n, m, x, ans, v[N]; pii c[N]; ll find_maximum(int k, vector<vector<int>>r){ n=r.sz(); m=r[0].sz(); vector<vector<int>>y; y.resize(n); for(int i=0; i<n; i++) v[i]=r[i][0], y[i].pb(0); sort(v, v+n); for(int i=0; i<n; i++){ c[i].ss=v[n-1]-v[i], c[i].ss+=c[i-1].ss; c[i].ff=v[i]-v[0], c[i].ff+=c[i-1].ff; } ll mn=1e18, in; for(int i=0; i<n; i++){ //~ cout<<i<<' '<<c[i].ff<<' '<<c[i].ss<<' '; ll ans=c[i].ss-(v[n-1]-v[i])*(i+1); // cout<<ans<<' '; // if((c[n-1].ff-c[i].ff)>(v[i]-v[0])*(n-i)) ans+=(c[n-1].ff-c[i].ff)-(v[i]-v[0])*(n-i-1); // cout<<ans<<' '<<c[n-1].ff-c[i].ff<<' '<<c[n-1].ff<<'\n'; mn=min(mn, ans); if(mn==ans) in=i; } //~ cout<<in<<' '; allocate_tickets(y); return mn; } /* int main(){ int k; int l, r, y; vector<vector<int>>c; cin>>l>>r>>k; c.resize(l); for(int i=0; i<l; i++) for(int j=0; j<r; j++) cin>>y, c[i].pb(y); cout<<find_maximum(k, c); } */

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:31:14: warning: variable 'in' set but not used [-Wunused-but-set-variable]
   31 |  ll mn=1e18, in;
      |              ^~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...