# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
926544 | Toast | Snail (NOI18_snail) | C++14 | 3 ms | 860 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
int main() {
double H,N,diff;
long maxim=0;
long currentheight=0;
long currentphase=0;
long temp = -1;
bool flag = true;
string P;
cin >> H >> N;
cin.ignore();
getline(cin, P);
stringstream ss(P);
vector<long>v;
vector<long>max;
while (getline(ss,P,' ')) {
v.push_back(stoul(P));
}
long currentday = -1;
for (int i=0;i<2;i++) {
currentday++;
for (int i=0;i<N;i++) {
if (currentheight+v[i]<0) {
currentheight = 0;
}
else {
currentheight +=v[i];
if (currentheight>maxim) {
maxim=currentheight;
}
}
if (currentheight>=H) {
flag=false;
currentphase=i;
cout << currentday << " " << currentphase;
break;
}
}
max.push_back(maxim);
if (!flag) {
break;
}
if (temp==currentheight) {
cout << -1 << " " << -1;
flag = false;
break;
}
diff = currentheight-temp;
temp = currentheight;
}
currentday=ceil((H-max[0])/(max[1]-max[0]));
temp = currentheight+(currentday-2)*diff;
while (flag) {
for (int i=0;i<N;i++) {
if (v[i]+temp>=H) {
cout << currentday << " " << i;
flag = false;
break;
}
else {
temp+=v[i];
}
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |