제출 #318299

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
3182992020-11-01 02:49:12ryangohcaDischarging (NOI20_discharging)C++17
100 / 100
446 ms25828 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int nums[1000001], dp[1000001];
deque<pair<int,int> > dq;
int f(pair<int,int> line, int x){
return line.first*x + line.second;
}
int query(int x){
while(dq.size()>1){ //to prevent seg fault when accessing dq[1]
if(f(dq[0],x)<f(dq[1],x)) //the next line is better
dq.pop_front(); //remove useless line
else break;
}
return f(dq[0],x);
}
double intersect(int m1, int c1, int m2, int c2){
return (double)(c2-c1)/(m1-m2);
}
double intersect(pair<int,int> p1, pair<int,int> p2){
return intersect(p1.first,p1.second,p2.first,p2.second);
}
void insert(int m,int c) {//insert line y=mx+c
pair<int,int> line = make_pair(m,c);
while (dq.size()>1) { //to prevent seg fault
int s = dq.size();
if (intersect(dq[s-1], line) <= intersect(dq[s-2], line))
dq.pop_back(); //removes useless line
else break;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

Discharging.cpp:33:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main(){
      |      ^
#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...