이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
*/
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |