Submission #1295241

#TimeUsernameProblemLanguageResultExecution timeMemory
1295241luattapcodePotatoes and fertilizers (LMIO19_bulves)C++20
0 / 100
1034 ms36012 KiB
/*The best way to get something done is to begin*/ #include <bits/stdc++.h> #define ll long long //#define int long long #define fr(i,a,b) for(int i=a;i<=b;i++) #define frd(i,a,b) for(int i=a;i>=b;i--) #define pb push_back #define fi first #define se second #define el '\n' using namespace std; template <class X, class Y> bool minimize(X &x, const Y &y) {if (x > y) {x = y;return true;} else return false;} template <class X, class Y> bool maximize(X &x, const Y &y) {if (x < y) {x = y;return true;} else return false;} /* Author: Huynh Quoc Luat */ /*Khai Bao*/ const long long inf=1e18; const int oo=1e9; const int LO=21; const int CH=27; const int sm=1e9+7; //void add(int &x,const int &y){x+=y;if(x>=sm)x-=sm;} //void sub(int &x,const int &y){x-=y;if(x<0)x+=sm;} const int N = 5e5 + 5; int d[N]; int n; void read() { cin >> n; fr(i,1,n){ int x,y; cin >> x >> y; d[i] = d[i-1] + x - y; } } namespace sub1 { const int N = 3005; int dp[N][N]; void process() { memset(dp,0x3f,sizeof dp); dp[0][0] = 0; fr(i,1,n){ fr(j,0,d[n]){ fr(k,0,j){ minimize(dp[i][j],dp[i-1][k] + abs(j - d[i])); } } } cout << dp[n][d[n]]; } } void time() {cerr<< endl<<"Luattapcode: "<<clock()<<"ms"<<endl;} main() { ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL); #define TASK "qn" if(fopen(TASK".INP","r")) { freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout); } int mtt=0; int test=1; if(mtt) cin>>test; while(test--) { read(); sub1::process(); } time(); return 0; }

Compilation message (stderr)

bulves.cpp:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | main()
      | ^~~~
bulves.cpp: In function 'int main()':
bulves.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bulves.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen(TASK".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...