Submission #625766

#TimeUsernameProblemLanguageResultExecution timeMemory
6257661ne카니발 티켓 (IOI20_tickets)C++14
11 / 100
2 ms564 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #include <vector> long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); long long sum = 0; vector<int>pos; for (int i = 0;i<n;++i){ for (int j = 0;j<m;++j){ sum+=x[i][j]; pos.push_back(x[i][j]); x[i][j] = 0; } } sort(pos.begin(),pos.end()); vector<int>valid = {pos[n/2],pos[n/2 - 1],sum / n,sum / n + 1,sum / n - 1}; long long ans = LLONG_MAX; for (auto x:valid){ long long curans = 0; for (auto y:pos){ curans+=abs(y - x); } ans = min(ans,curans); } for (int i = 0;i<n;++i){ for (int j = 0;j<m;++j){ x[i][j] = 0; } } allocate_tickets(x); return ans; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:19:48: warning: narrowing conversion of '(sum / ((long long int)n))' from 'long long int' to 'int' [-Wnarrowing]
   19 |  vector<int>valid = {pos[n/2],pos[n/2 - 1],sum / n,sum / n  + 1,sum / n - 1};
      |                                            ~~~~^~~
tickets.cpp:19:48: warning: narrowing conversion of '(sum / ((long long int)n))' from 'long long int' to 'int' [-Wnarrowing]
tickets.cpp:19:61: warning: narrowing conversion of '((sum / ((long long int)n)) + 1)' from 'long long int' to 'int' [-Wnarrowing]
   19 |  vector<int>valid = {pos[n/2],pos[n/2 - 1],sum / n,sum / n  + 1,sum / n - 1};
      |                                                    ~~~~~~~~~^~~
tickets.cpp:19:61: warning: narrowing conversion of '((sum / ((long long int)n)) + 1)' from 'long long int' to 'int' [-Wnarrowing]
tickets.cpp:19:73: warning: narrowing conversion of '((sum / ((long long int)n)) - 1)' from 'long long int' to 'int' [-Wnarrowing]
   19 |  vector<int>valid = {pos[n/2],pos[n/2 - 1],sum / n,sum / n  + 1,sum / n - 1};
      |                                                                 ~~~~~~~~^~~
tickets.cpp:19:73: warning: narrowing conversion of '((sum / ((long long int)n)) - 1)' from 'long long int' to 'int' [-Wnarrowing]
#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...