Submission #875812

# Submission time Handle Problem Language Result Execution time Memory
875812 2023-11-20T14:27:59 Z resfast Skyscraper (JOI16_skyscraper) C++17
5 / 100
2000 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define islam_zymchybekov void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define endl '\n'
#define nl cout<<'\n';
#define int long long
#define stg string
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
typedef vector<int> vi;
typedef pair<int,int> pi;
void fopn(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
/*
talent is important,
as is the work we have to
do to achieve your goals... <Sorry, looks like I won't be able to go to the moon>©ciberpank

ok,enough quotes it's time to get to work
*/
struct V{
	int x1,y1,x2,y2;
	int ares(){
		return (abs(x2-x1))*(abs(y2-y1));
	}
};
int inter(V a,V b){
	int y = max(0ll,min(a.y2,b.y2)-max(a.y1,b.y1));
	int x = max(0ll,min(a.x2,b.x2)-max(a.x1,b.x1));
	return x*y;
}
int binpow(int a, int n){
    if(n == 0)
        return 1;
    if(n % 2 == 1)
        return binpow(a, n - 1) * a;
    else{
        int b = binpow(a, n / 2);
        return b * b;
    }
}

string s;
int a[1000000];
char ch[1002][1002];
int c,n,m,i,j,k,x,y,cnt=0,res=0,l=0,mx=-1,sum=0,nx=-1;
const int mod =1e9+7;
islam_zymchybekov{
	cin>>n>>m;vi v(n);
	for(auto &x:v){
		cin>>x;
	}sort(all(v));
	int ans1=0;
	do{
		int ans=0;
		for(i=0;i<n-1;i++){
			ans+=abs(v[i]-v[i+1]);
		}
		if(ans<=m)ans1=(ans1+1)%mod;
//		cout<<ans;nl;
	}while(next_permutation(all(v)));
 	cout<<ans1;	
 }
 main(){
    ios;
    int T = 1;
//	    cin >> T;
    while(T--){
        solve();
    }
}






Compilation message

skyscraper.cpp:74:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   74 |  main(){
      |  ^~~~
skyscraper.cpp: In function 'void fopn(std::string)':
skyscraper.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen((name+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen((name+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2009 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Execution timed out 2009 ms 348 KB Time limit exceeded
12 Halted 0 ms 0 KB -