Submission #1117538

#TimeUsernameProblemLanguageResultExecution timeMemory
1117538heeheeheehaawNile (IOI24_nile)C++17
23 / 100
2050 ms11488 KiB
#include <iostream> #include <fstream> #include <vector> #include <cmath> #include <algorithm> #include "nile.h" using namespace std; struct art { long long w,a,b; }; bool compare(art a,art b) { return a.w<b.w; } vector<art> artifact; long long sol(vector<art> v,long long d) { long long price=0; for(long long i=0;i<v.size();i++) { price+=v[i].b; } if((int)v.size()%2==0) return price; long long minn=999999999999999999; for(long long i=0;i<v.size();i++) { if(((i==0) or (i==((int)v.size()-1))) or (abs(v[i - 1].w-v[i + 1].w)<=d)) minn=min(minn,(long long)(v[i].a-v[i].b)); } return price+minn; } vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) { long long n = W.size(); for(long long i=0;i<n;i++) { art x; x.w = W[i]; x.a = A[i]; x.b = B[i]; artifact.push_back(x); } sort(artifact.begin(),artifact.end(),compare); long long q = E.size(); long long price=0; vector<long long> R; for(long long matale = 0; matale < q; matale++) { price=0; long long d = E[matale]; vector<art> v; v.push_back(artifact[0]); for(long long i=1;i<artifact.size();i++) { if(abs(artifact[i-1].w-artifact[i].w)<=d) v.push_back(artifact[i]); else price+=sol(v,d),v.clear(),v.push_back(artifact[i]); } price+=sol(v,d); R.push_back(price); } return R; } /* 5 15 5 1 12 4 2 2 5 2 10 6 3 21 3 2 3 5 9 1 */

Compilation message (stderr)

nile.cpp: In function 'long long int sol(std::vector<art>, long long int)':
nile.cpp:24:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<art>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(long long i=0;i<v.size();i++)
      |                       ~^~~~~~~~~
nile.cpp:31:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<art>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(long long i=0;i<v.size();i++)
      |                       ~^~~~~~~~~
nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:60:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<art>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         for(long long i=1;i<artifact.size();i++)
      |                           ~^~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...