Submission #828384

#TimeUsernameProblemLanguageResultExecution timeMemory
828384AmylopectinRadio Towers (IOI22_towers)C++17
23 / 100
4086 ms48440 KiB
#include "towers.h"
#include <stdio.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mxn = 2e6 + 10,mxi = 2e9 + 10;
int n,he[mxn] = {};
vector<int> se[mxn] = {};
void init(int N, std::vector<int> H) 
{
  int i,j,cn,cm,fn,fm;
  n = N;
  for(i=0; i<n; i++)
  {
    he[i] = H[i];
  }
  return ;
}

int max_towers(int cl, int cr, int d) 
{
  int i,j,cn,cm,fn,fm,cmi = -1,cma,beh = mxi,cou = 0;
  for(i=cl; i<=cr; i++)
  {
    if(cmi == -1)
    {
      cmi = he[i];
    }
    else 
    {
      cmi = min(cmi,he[i]);
    }
    if(he[i] - cmi >= d && beh - cmi >= d)
    {
      cou ++;
      beh = he[i];
      cmi = -1;
    }
    else 
    {
      if(he[i] > beh)
      {
        beh = he[i];
        cmi = -1;
      }
    }
  }
  if(cmi != -1 && beh - cmi >= d)
  {
    cou ++;
  }
  return cou;
}

Compilation message (stderr)

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:12:9: warning: unused variable 'j' [-Wunused-variable]
   12 |   int i,j,cn,cm,fn,fm;
      |         ^
towers.cpp:12:11: warning: unused variable 'cn' [-Wunused-variable]
   12 |   int i,j,cn,cm,fn,fm;
      |           ^~
towers.cpp:12:14: warning: unused variable 'cm' [-Wunused-variable]
   12 |   int i,j,cn,cm,fn,fm;
      |              ^~
towers.cpp:12:17: warning: unused variable 'fn' [-Wunused-variable]
   12 |   int i,j,cn,cm,fn,fm;
      |                 ^~
towers.cpp:12:20: warning: unused variable 'fm' [-Wunused-variable]
   12 |   int i,j,cn,cm,fn,fm;
      |                    ^~
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:23:9: warning: unused variable 'j' [-Wunused-variable]
   23 |   int i,j,cn,cm,fn,fm,cmi = -1,cma,beh = mxi,cou = 0;
      |         ^
towers.cpp:23:11: warning: unused variable 'cn' [-Wunused-variable]
   23 |   int i,j,cn,cm,fn,fm,cmi = -1,cma,beh = mxi,cou = 0;
      |           ^~
towers.cpp:23:14: warning: unused variable 'cm' [-Wunused-variable]
   23 |   int i,j,cn,cm,fn,fm,cmi = -1,cma,beh = mxi,cou = 0;
      |              ^~
towers.cpp:23:17: warning: unused variable 'fn' [-Wunused-variable]
   23 |   int i,j,cn,cm,fn,fm,cmi = -1,cma,beh = mxi,cou = 0;
      |                 ^~
towers.cpp:23:20: warning: unused variable 'fm' [-Wunused-variable]
   23 |   int i,j,cn,cm,fn,fm,cmi = -1,cma,beh = mxi,cou = 0;
      |                    ^~
towers.cpp:23:32: warning: unused variable 'cma' [-Wunused-variable]
   23 |   int i,j,cn,cm,fn,fm,cmi = -1,cma,beh = mxi,cou = 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...