Submission #142641

#TimeUsernameProblemLanguageResultExecution timeMemory
142641Ruxandra985Cover (COCI18_cover)C++14
120 / 120
25 ms504 KiB
#include <cstdio> #include <iostream> #include <algorithm> #define DIMN 5010 using namespace std; long long d[DIMN]; struct punct { int x,y; } v[DIMN]; int cmp (punct a , punct b){ if (a.x != b.x) return a.x < b.x; return a.y < b.y; } int main() { //FILE *fin = fopen ("a.in","r"); //FILE *fout = fopen ("a.out","w"); int n,i,ymax,j; scanf ("%d",&n); for (i=1;i<=n;i++){ scanf ("%d%d",&v[i].x , &v[i].y); v[i].x = max (v[i].x , -v[i].x); v[i].y = max (v[i].y , -v[i].y); } sort (v+1 , v+n+1 , cmp); for (i=1;i<=n;i++){ ymax = -1; d[i] = 1000000000000000000; for (j = i-1; j>=0 ; j--){ ymax = max(ymax , v[j+1].y); /// de la j+1 .. i , un nou dreptunghi d[i] = min (d[i] , d[j] + (long long)ymax * v[i].x); } } printf ( "%lld" , d[n] * 4); return 0; }

Compilation message (stderr)

cover.cpp: In function 'int main()':
cover.cpp:20:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d",&n);
     ~~~~~~^~~~~~~~~
cover.cpp:22:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d%d",&v[i].x , &v[i].y);
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...