답안 #48226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48226 2018-05-10T23:59:16 Z qkrghdqls1 Boat (APIO16_boat) C++14
0 / 100
2000 ms 524288 KB
#include<bits/stdc++.h>
using namespace std;
int a[501],b[501],mod=1000000007;
vector<int> v;
unordered_map<int,int> m;
map<int,int> su;
int main()
{
	/*int n,cnt=1;
	  scanf("%d",&n);
	  for(int i=1;i<=n;i++){
	  scanf("%d %d",&a[i],&b[i]);
	  v.push_back(a[i]);
	  v.push_back(b[i]);
	  }
	  sort(v.begin(),v.end());
	  unique(v.begin(),v.end());
	  while(cnt<v.size()&&v[cnt-1]<v[cnt]) cnt++;*/
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);
		for(int j=a[i];j<=b[i];j++) m[j]=0;
	}
	m[0]=1;
	int s=0;
	for(int i=0;i<n;i++){
		s=0;
		for(auto it=m.begin();it!=m.end();it++){
			s=(s+it->second)%mod;
			su[it->first]=s;
		}
		for(int j=b[i];j>=a[i];j--)
		{
			auto it=su.find(j);
			auto it2=m.find(j);
			it--;
			m[j]=(m[j]+it->second)%mod;
		}
	}
	s=0;
	for(auto it=m.begin();it!=m.end();it++){
		s=(s+it->second)%mod;
		su[it->first]=s;
	}
	printf("%d",(s-1+mod)%mod);
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:36:9: warning: variable 'it2' set but not used [-Wunused-but-set-variable]
    auto it2=m.find(j);
         ^~~
boat.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
boat.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&a[i],&b[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2061 ms 524288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -