제출 #123920

#제출 시각아이디문제언어결과실행 시간메모리
123920AyaBenSaadJakarta Skyscrapers (APIO15_skyscraper)C++14
0 / 100
225 ms262148 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 3; //number of skyscrapers const int M = 3e4 + 4; //number of doges; const int inf = 2e9; int n, m, b[M], p[M], ok; vector <int> dgin[N]; long long dp[M][N]; long long solve (int doge, int sk) { if (doge == 1) {ok = 1; return 0;} if (sk < 0 || sk >= n) return inf; long long &ret = dp[doge][sk]; if (ret != -1) return ret; ret = solve(doge, sk+p[doge]) + 1; ret = min(ret, solve(doge, sk-p[doge]) + 1); for (int i : dgin[sk]) { if (i != doge) ret = min (ret, solve(i, sk)); } return ret; } int main () { scanf ("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d %d", &b[i], &p[i]); dgin[b[i]].push_back (i); } memset (dp, -1, sizeof dp); long long x = solve(0, b[0]); if(ok) printf("%lld\n", x); else puts("-1"); }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:26:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &n, &m);
     ~~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &b[i], &p[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...