제출 #328805

#제출 시각아이디문제언어결과실행 시간메모리
328805ryangohcaSnail (NOI18_snail)C++17
37 / 100
6 ms768 KiB
#include <bits/stdc++.h> #define int long long using namespace std; vector<int> changes; main() { int h, n; cin >> h >> n; for (int i = 0; i < n*2; i++){ if (i >= n){ changes.push_back(changes[i-n]); } else { int g; cin >> g; changes.push_back(g); } } int s = 0; for (int i = 0; i < n*2; i++){ s += changes[i]; s = max(s, 0ll); if (s >= h){ cout << i/n << ' ' << i%n << '\n'; return 0; } } s = accumulate(changes.begin(), changes.end(), 0ll); if (s <= 0) { cout << "-1 -1\n"; return 0; } else { int d = h/s * 2; int climbed = d/2*s; if (climbed >= h){ cout << d - 1 << ' ' << n - 1 << "\n"; return 0; } for (int i = 0; i < n*2; i++){ if (i == n) d++; climbed += changes[i]; if (climbed >= h){ cout << d << ' ' << i % n << '\n'; return 0; } } } }

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

snail.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | 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...