제출 #1117531

#제출 시각아이디문제언어결과실행 시간메모리
1117531heeheeheehaaw나일강 (IOI24_nile)C++17
17 / 100
2037 ms9336 KiB
#include <iostream> #include <fstream> #include <vector> #include <cmath> #include <algorithm> #include "nile.h" using namespace std; struct art { int w,a,b; }; bool compare(art a,art b) { return a.w<b.w; } vector<art> artifact; long long sol(vector<art> v,int d) { long long price=0; for(int i=0;i<v.size();i++) { price+=v[i].b; } if(v.size()%2==0) return price; long long minn=999999999999999999; for(int i=0;i<v.size();i++) { if((i==0 or i==v.size()-1) or (abs(v[i].a-v[i].b)<=d)) minn=min(minn,(long long)abs(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) { int n = W.size(); for(int 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); int q = E.size(); long long price=0; vector<long long> R; for(int matale = 0; matale < q; matale++) { price=0; int d = E[matale]; vector<art> v; v.push_back(artifact[0]); for(int 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; }

컴파일 시 표준 에러 (stderr) 메시지

nile.cpp: In function 'long long int sol(std::vector<art>, int)':
nile.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<art>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
nile.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<art>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
nile.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<art>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if((i==0 or i==v.size()-1) or (abs(v[i].a-v[i].b)<=d))
      |                     ~^~~~~~~~~~~~
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:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<art>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for(int 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...