Submission #2237776
Source Code Expand
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template<class T>
inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
//sqrt
//-------------------------------------------
template<class T>
inline T sqr(T x) { return x * x; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<bool> VB;
typedef vector<VI> VVI;
typedef vector<VB> VVB;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
//repetition
//------------------------------------------
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define REPR(i, n) for(int i = n;i >= 0;i--)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
//partial_permutation nPr
//first・・最初の数
//middle・・r(取り出す数)
//last・・n(全体数)
template<class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last) {
reverse(middle, last);
return next_permutation(first, last);
}
//combination nCr
//first1・・最初の数
//last1==first2・・r(取り出す数)
//last2・・n(全体数)
template<class BidirectionalIterator>
bool next_combination(BidirectionalIterator first1, BidirectionalIterator last1, BidirectionalIterator first2,
BidirectionalIterator last2) {
if ((first1 == last1) || (first2 == last2)) {
return false;
}
BidirectionalIterator m1 = last1;
BidirectionalIterator m2 = last2;
--m2;
while (--m1 != first1 && !(*m1 < *m2)) {
}
bool result = (m1 == first1) && !(*first1 < *m2);
if (!result) {
while (first2 != m2 && !(*m1 < *first2)) {
++first2;
}
first1 = m1;
std::iter_swap(first1, first2);
++first1;
++first2;
}
if ((first1 != last1) && (first2 != last2)) {
m1 = last1;
m2 = first2;
while ((m1 != first1) && (m2 != last2)) {
std::iter_swap(--m1, m2);
++m2;
}
std::reverse(first1, m1);
std::reverse(first1, last1);
std::reverse(m2, last2);
std::reverse(first2, last2);
}
return !result;
}
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main() {
int T;
cin >> T;
int N;
cin >> N;
VI A(N);
REP(i, N) {
scanf("%d", &A[i]);
}
int M;
cin >> M;
VI B(M);
REP(i, M) {
scanf("%d", &B[i]);
}
bool good = true;
int takoCount = 0;
REP(i, M) {
int guestTime = B[i];
bool exist = false;
for (int j = takoCount; j < N; j++) {
if (A[j] <= guestTime
&& (A[j] + T >= guestTime)
) {
exist = true;
takoCount = j+1;
break;
}
}
if(!exist){
good = false;
}
}
if(good){
cout <<"yes"<<endl;
}else{
cout<<"no" << endl;
}
return 0;
}
Submission Info
Submission Time |
|
Task |
C - おいしいたこ焼きの売り方 |
User |
ganyariya |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
4619 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:148:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &A[i]);
^
./Main.cpp:154:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &B[i]);
^
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
rand0.txt, rand1.txt, rand10.txt, rand11.txt, rand12.txt, rand13.txt, rand14.txt, rand15.txt, rand16.txt, rand17.txt, rand18.txt, rand19.txt, rand2.txt, rand20.txt, rand21.txt, rand22.txt, rand23.txt, rand24.txt, rand25.txt, rand26.txt, rand27.txt, rand28.txt, rand29.txt, rand3.txt, rand4.txt, rand5.txt, rand6.txt, rand7.txt, rand8.txt, rand9.txt, s1.txt, s2.txt, s3.txt, s4.txt, s5.txt |
Case Name |
Status |
Exec Time |
Memory |
rand0.txt |
AC |
1 ms |
256 KB |
rand1.txt |
AC |
1 ms |
256 KB |
rand10.txt |
AC |
1 ms |
256 KB |
rand11.txt |
AC |
1 ms |
256 KB |
rand12.txt |
AC |
1 ms |
256 KB |
rand13.txt |
AC |
1 ms |
256 KB |
rand14.txt |
AC |
1 ms |
256 KB |
rand15.txt |
AC |
1 ms |
256 KB |
rand16.txt |
AC |
1 ms |
256 KB |
rand17.txt |
AC |
1 ms |
256 KB |
rand18.txt |
AC |
1 ms |
256 KB |
rand19.txt |
AC |
1 ms |
256 KB |
rand2.txt |
AC |
1 ms |
256 KB |
rand20.txt |
AC |
1 ms |
256 KB |
rand21.txt |
AC |
1 ms |
256 KB |
rand22.txt |
AC |
1 ms |
256 KB |
rand23.txt |
AC |
1 ms |
256 KB |
rand24.txt |
AC |
1 ms |
256 KB |
rand25.txt |
AC |
1 ms |
256 KB |
rand26.txt |
AC |
1 ms |
256 KB |
rand27.txt |
AC |
1 ms |
256 KB |
rand28.txt |
AC |
1 ms |
256 KB |
rand29.txt |
AC |
1 ms |
256 KB |
rand3.txt |
AC |
1 ms |
256 KB |
rand4.txt |
AC |
1 ms |
256 KB |
rand5.txt |
AC |
1 ms |
256 KB |
rand6.txt |
AC |
1 ms |
256 KB |
rand7.txt |
AC |
1 ms |
256 KB |
rand8.txt |
AC |
1 ms |
256 KB |
rand9.txt |
AC |
1 ms |
256 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |
s3.txt |
AC |
1 ms |
256 KB |
s4.txt |
AC |
1 ms |
256 KB |
s5.txt |
AC |
1 ms |
256 KB |