Submission #380916

#TimeUsernameProblemLanguageResultExecution timeMemory
380916Pichon5Carnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms364 KiB
#include "tickets.h" #include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair using namespace std; long long find_maximum(int k,vector<vi> x) { int n = x.size(); int m = x[0].size(); ll res=0; ll sum=0; vector<vi>M(n,vi(m,-1)); vector<pair<int,int> >ind(n+1); vector<pair<int,int> >cant(n+1);//blanco y negro for(int i=0;i<n;i++)ind[i]={0,m-1}; for(int i=0;i<n;i++){ int a=0,b=0; for(int l=0;l<m;l++){ if(x[i][l]==0){ a++; }else{ b++; } } cant[i]={a,b}; } vi v; for(int i=0;i<k;i++){ v.clear(); int a=0,b=0,aux=0; for(int l=0;l<n;l++){ if(cant[l].S==0){ a++; M[l][ind[l].F]=i; ind[l].F++; continue; } if(cant[l].F==0){ b++; M[l][ind[l].S]=i; ind[l].S--; continue; } v.pb(l); } for(int l=0;l<v.size();l++){ if(a<=b){ a++; M[v[l]][ind[v[l]].S]=i; cant[v[l]].S--; }else{ b++; M[v[l]][ind[v[l]].F]=i; cant[v[l]].F--; } } res+=min(a,b); } allocate_tickets(M); return res; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int l=0;l<v.size();l++){
      |                     ~^~~~~~~~~
tickets.cpp:36:21: warning: unused variable 'aux' [-Wunused-variable]
   36 |         int a=0,b=0,aux=0;
      |                     ^~~
tickets.cpp:17:5: warning: unused variable 'sum' [-Wunused-variable]
   17 |  ll sum=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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...