Submission #890409

#TimeUsernameProblemLanguageResultExecution timeMemory
890409Faisal_SaqibSails (IOI07_sails)C++17
25 / 100
1035 ms65536 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; #define int long long const int M=1e5+100; int cnt[M]; long long mx=1e18,ans=0; int n; vector<pair<int,int>> a; long long f(long long x) { return (x*(x+1))/2; } void recur(int x); void place(int curh,int mxh,int curpl,int pl,int x) { if(curpl==pl) { recur(x+1); return; } if(curh==mxh) { return; } ans+=cnt[curh]; cnt[curh]++; place(curh+1,mxh,curpl+1,pl,x); cnt[curh]--; ans-=cnt[curh]; place(curh+1,mxh,curpl,pl,x); } void recur(int x) { if(ans>=mx) { return; } if(x==n) { mx=min(mx,ans); return; } place(0,a[x].first,0,a[x].second,x); } signed main() { cin>>n; for(int i=0;i<n;i++) { int h,k; cin>>h>>k; a.push_back({h,k}); } recur(0); cout<<mx<<endl; return 0; }
#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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...