Submission #307207

#TimeUsernameProblemLanguageResultExecution timeMemory
307207Ruxandra985Carnival Tickets (IOI20_tickets)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> #include "tickets.h" #define DIMN 1510 #define MLD 1000000000 using namespace std; void allocate_tickets( vector<vector<int>> _d); long long spl[DIMN][DIMN] , spr[DIMN][DIMN]; int prefix[DIMN] , sufix[DIMN]; int f[DIMN]; vector <long long> dp[DIMN] , tt[DIMN]; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size() , i , j , take , l , r , poz , st , dr; int m = x[0].size(); long long sol = 0 , maxi; vector<vector<int>> answer; for (i = 0; i < n; i++) { vector<int> row; row.resize(m , -1); answer.push_back(row); sufix[i] = m; prefix[i] = k - 1; } for (i = 0 ; i < n ; i++){ for (j = 0 ; j < k ; j++) sol -= x[i][j]; } int can = 1; for (j = 1 ; j <= n * k / 2 ; j++){ maxi = -1000000000000000000; poz = -1; for (i = 0 ; i < n ; i++){ if (prefix[i] && maxi < sol + x[i][prefix[i]] + x[i][sufix[i] - 1]){ maxi = sol + x[i][prefix[i]] + x[i][sufix[i] - 1]; // if (maxi < -35) // printf ("a"); poz = i; } } sol = maxi; prefix[poz]--; sufix[poz]--; } i = n; st = 0; while (i){ l = prefix[i - 1] + 1; printf ("%d\n" , l); for (r = 0 ; r < l ; r++){ answer[i - 1][r] = st; st = (st + 1) % k; } dr = st; for (r = 0 ; r < k - l ; r++){ answer[i - 1][m - 1 - r] = dr; dr = (dr + 1) % k; } i--; } allocate_tickets(answer); return sol; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:17:29: warning: unused variable 'take' [-Wunused-variable]
   17 |  int n = x.size() , i , j , take , l , r , poz , st , dr;
      |                             ^~~~
tickets.cpp:36:6: warning: unused variable 'can' [-Wunused-variable]
   36 |  int can = 1;
      |      ^~~
#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...