This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define ll long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod = 1000000007 ;
const int mod1 = 998244353 ;
const int NN = 2e5 + 10 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;
#include "tickets.h"
// static int n;
// static int m;
// static int k;
// static std::vector<std::vector<int>> d;
// static std::vector<std::vector<int>> x;
// static int called = 0;
// static void check(bool cond, std::string message) {
// if (!cond) {
// printf("WA\n");
// printf("%s\n", message.c_str());
// exit(0);
// }
// }
// void allocate_tickets( std::vector<std::vector<int>> _d) {
// check(!called, "allocate_tickets called more than once");
// d = _d;
// check((int)d.size() == n, "allocate_tickets called with parameter of wrong size");
// for (int i = 0; i < n; i++) {
// check((int)d[i].size() == m, "allocate_tickets called with parameter of wrong size");
// }
// called = 1;
// }
long long find_maximum(int k, std::vector<std::vector<int>> d){
vector<std::vector<int>> pas ;
FOR( i , d.size() ){
vector < int > pas1 ;
FOR( j , d[ i ].size() ) pas1.pb( 0 ) ;
pas.pb( pas1 ) ;
}
ll ans = inf ;
double sum = 0 ;
double cnt = 0 ;
for( auto x : d ){
sum += x[ 0 ] ;
cnt ++ ;
}
sum /= cnt ;
int x = sum ;
int cc = 0 , cc1 = 0 ;
for( auto y : d ) if( y[ 0 ] > x ) cc ++ ; else cc1 ++ ;
if( cc > cc1 ) x ++ ;
ans = 0 ;
for( auto y : d ) ans += abs( y[ 0 ] - x ) ;
allocate_tickets( pas ) ;
return ans ;
}
// int main() {
// assert(scanf("%d %d %d", &n, &m, &k) == 3);
// x.resize(n);
// for (int i = 0; i < n; i++) {
// x[i].resize(m);
// for (int j=0; j < m; j++) {
// assert(scanf("%d", &x[i][j]) == 1);
// }
// }
// fclose(stdin);
// long long answer = find_maximum(k, x);
// check(called, "failure to call allocate_tickets");
// printf("OK\n");
// printf("%lld\n", answer);
// for (int i = 0; i < n; i++) {
// for (int j = 0; j < m; j++) {
// if (j) printf(" ");
// printf("%d", d[i][j]);
// }
// printf("\n");
// }
// fclose(stdout);
// return 0;
// }
Compilation message (stderr)
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:12:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | #define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
......
65 | FOR( i , d.size() ){
| ~~~~~~~~~~~~
tickets.cpp:65:6: note: in expansion of macro 'FOR'
65 | FOR( i , d.size() ){
| ^~~
tickets.cpp:12:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | #define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
......
67 | FOR( j , d[ i ].size() ) pas1.pb( 0 ) ;
| ~~~~~~~~~~~~~~~~~
tickets.cpp:67:9: note: in expansion of macro 'FOR'
67 | FOR( j , d[ i ].size() ) pas1.pb( 0 ) ;
| ^~~
# | 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... |