Submission #1079972

#TimeUsernameProblemLanguageResultExecution timeMemory
1079972TrumlingHorses (IOI15_horses)C++14
17 / 100
23 ms8284 KiB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 9999999999999999
typedef long long ll;
ll n;
vector<int>sell;
int init(int N, int X[], int Y[]) {
	n=N;
	
	ll curr=1;
	for(int i=n-1;i>=0;i--)
	{
		if(sell.empty() || Y[sell[sell.size()-1]]*curr < Y[i])
		{
			sell.pb(i);
			curr=1;
		}
		curr*=X[i];
	}

	for(int i=0;i<sell.size()/2;i++)
		swap(sell[i],sell[sell.size()-1-i]);

	//for(int i=0;i<sell.size();i++)
		//cout<<sell[i]<<' ';
	ll idx=0;
	ll ans=0;
	curr=1;
	for(int i=0;i<n;i++)
		{
			curr*=X[i];
			if(sell[idx]==i)
			{
				ans+=curr*Y[i];
				idx++;
				curr=0;
			}
		}

	return ans;

}

int updateX(int pos, int val) {	
	return 0;
}

int updateY(int pos, int val) {
	return 0;
}

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:17:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   17 |  for(int i=n-1;i>=0;i--)
      |            ~^~
horses.cpp:27:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i=0;i<sell.size()/2;i++)
      |              ~^~~~~~~~~~~~~~
horses.cpp:46:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   46 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:50:17: warning: unused parameter 'pos' [-Wunused-parameter]
   50 | int updateX(int pos, int val) {
      |             ~~~~^~~
horses.cpp:50:26: warning: unused parameter 'val' [-Wunused-parameter]
   50 | int updateX(int pos, int val) {
      |                      ~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:54:17: warning: unused parameter 'pos' [-Wunused-parameter]
   54 | int updateY(int pos, int val) {
      |             ~~~~^~~
horses.cpp:54:26: warning: unused parameter 'val' [-Wunused-parameter]
   54 | int updateY(int pos, int val) {
      |                      ~~~~^~~
#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...