이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <iomanip>
#include <stack>
#include <fstream>
using namespace std;
long long int maximo(long long int s,vector<pair<long long int,long long int> >&p,long long int & hi,long long int & low,int nodo){
if(nodo==p.size()){
return s;
}
else{
if(hi==0 && low==1e15+1){
return max(maximo(s+p[nodo].second,p,p[nodo].first,p[nodo].first,nodo+1),maximo(s,p,hi,low,nodo+1));
}
if(p[nodo].first>=low && p[nodo].first<=hi){
return maximo(s+p[nodo].second,p,hi,low,nodo+1);
}
else if(p[nodo].first>hi){
return max(maximo(s+p[nodo].second-(p[nodo].first-hi),p,p[nodo].first,low,nodo+1),maximo(s,p,hi,low,nodo+1));
}
else{
return max(maximo(s+p[nodo].second-(low-p[nodo].first),p,hi,p[nodo].first,nodo+1),maximo(s,p,hi,low,nodo+1));
}
}
}
int main(){
int n;
cin>>n;
vector<pair<long long int,long long int> >p(n);
for(int i=0;i<n;i++){
cin>>p[i].first>>p[i].second;
}
long long int hi=0,low=1e15+1;
cout<<maximo(0,p,hi,low,0);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp: In function 'long long int maximo(long long int, std::vector<std::pair<long long int, long long int> >&, long long int&, long long int&, int)':
art.cpp:16:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | if(nodo==p.size()){
| ~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |