제출 #844480

#제출 시각아이디문제언어결과실행 시간메모리
844480vjudge1Holding (COCI20_holding)C++17
0 / 110
36 ms80976 KiB
// Imagine not FFT #include <bits/stdc++.h> #ifndef ONLINE_JUDGE #define DEBUG(x) std::cerr << #x << ": " << x << std::endl; #define DEBUGV(x) std::cerr << #x << ": { "; for(auto ___y:x) std::cerr << ___y << " "; std::cerr << "}" << std::endl; #define DEBUGVV(x) std::cerr << #x << ": { \n"; for(int _i=0;_i<sz(x);++_i) {DEBUGV(x[_i]);} std::cerr << "}" << std::endl; #define DEBUGVP(x) std::cerr << #x << ": { "; for(auto ___y:x) std::cerr << "{" << ___y.first << "," << ___y.second << "}" << " "; std::cerr << "}" << std::endl; #define files freopen("in.txt","r",stdin);freopen("out.txt","w",stdout); #define fastio std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); #else #define fastio std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); #define DEBUG(...) void(23) #define DEBUGV(x) void(23); #define DEBUGARR(arr, size) void(23) #define DEBUGPRINT(...) void(23) #define DEBUGMAP(...) void(23) #define DEBUGMAPQUEUE(...) void(23) #define DEBUGVV(x) void(23); #define DEBUGVP(x) void(23); #define files void(23); #endif #define int long long #define ll long long #define pb push_back #define ff first #define ss second #define pii std::pair < int , int > #define pll std::pair < ll , ll > #define vi std::vector < ll > #define vl std::vector < int > #define vii std::vector < pii > #define vll std::vector < pll > #define vvi std::vector < vi > #define vvii std::vector < vii > #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define forn(i,j) for(int i=0;i<j;i++) #define forr(i,j,k) for(int i=j;i<k;i++) #define mset multiset #define pqueue priority_queue #define cmax(a,b) (a = max(a,b)) #define cmin(a,b) (a = min(a,b)) #define sz(a) (int)(a.size()) #define yes std::cout << "YES\n"; #define no std::cout << "NO\n"; using namespace std; int calc(int ans, int ind, vvi& cost, int len,vi& change, vi& from, int k,int limit,vector<int>& chosen,bool deb=true){ //if(ind<limit&&deb)cerr << ind << " " << ans << endl; //if(ind<limit&&deb){DEBUGV(chosen);} if(k==0 || ind>=limit) return ans; int tans = ans; forn(i,len){ //if(deb)cerr << "Win for {" << ind << "," << i << "} is " << calc(ans,ind+1,cost,len,change,from,k-cost[ind][i],limit,chosen,false) << " + " << change[i] << " - " << from[ind] << " = " << calc(ans,ind+1,cost,len,change,from,k-cost[ind][i],limit,chosen,false)+change[i]-from[ind] << endl; if(chosen[i]==-1 && cost[ind][i]<=k) { chosen[i]=i; tans = min(tans,calc(ans,ind+1,cost,len,change,from,k-cost[ind][i],limit,chosen)-from[ind]+change[i]); chosen[i]=-1; } } return (min(tans,calc(ans,ind+1,cost,len,change,from,k,limit,chosen))); } void solve(int _t_case){ DEBUG(_t_case); int n,l,r,k; cin >> n >> l >> r >> k; vi a(l-1); vi debt(r-l+1); vi b(n-r); for(int i=0;i<l-1;i++){ cin >> a[i]; } int ans = 0; for(int i=0;i<r-l+1;i++){ cin >> debt[i]; ans+=debt[i]; } for(int i=0;i<n-r;i++){ cin >> b[i]; } vvi cost(r-l+1,vi(n-r+l-1,1000000)); for(int d=0;d<sz(debt);d++){ for(int i=0;i<l-1;i++){ if(debt[i]>a[i]) cost[d][i]=d+l-1-i; } for(int i=0;i<n-r;i++){ if(debt[i]>b[i]) cost[d][i+l-1]=r+i-d-1; } } for(auto _b:b) a.pb(_b); vi chosen(n,-1); cout << calc(ans,0,cost,n-r+l-1,a,debt,k,sz(debt),chosen) << endl; DEBUGVV(cost); return; } signed main(){ fastio; files; int t=1,_t=0; // std::cin >> t; while(_t<t){ ++_t; solve(_t); } return 0; }

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

holding.cpp: In function 'int main()':
holding.cpp:9:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  #define files freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
holding.cpp:106:5: note: in expansion of macro 'files'
  106 |     files;
      |     ^~~~~
holding.cpp:9:51: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  #define files freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
      |                                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
holding.cpp:106:5: note: in expansion of macro 'files'
  106 |     files;
      |     ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...