Submission #890409

# Submission time Handle Problem Language Result Execution time Memory
890409 2023-12-21T06:14:18 Z Faisal_Saqib Sails (IOI07_sails) C++17
25 / 100
1000 ms 65536 KB
#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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 61 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 48 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 67 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 74 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 76 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -