Submission #123908

#TimeUsernameProblemLanguageResultExecution timeMemory
123908AyaBenSaadJakarta Skyscrapers (APIO15_skyscraper)C++14
0 / 100
271 ms235744 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]; vector <int> dgin[N]; int dp[M][N]; int solve (int doge, int sk) { if (doge == 1) return 0; if (sk < 0 || sk >= n) return inf; int &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]) { 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); printf("%d\n", solve(0, b[0])); }

Compilation message (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...