Submission #7814175


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int MAX = 2e6+1;
vector<PII> sushi(MAX,PII(-1,-1));

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  vector<int> shari(N);
  vector<int> neta(M);
  rep(i,N)cin >> shari[i];
  rep(j,M)cin >> neta[j];
  rep(i,N)rep(j,M){
    int weight = shari[i] + neta[j];
    if(sushi[weight].first != -1){
      cout << sushi[weight].first SP sushi[weight].second
        SP i SP j << endl;
      return 0;
    }
    sushi[weight] = PII(i,j);
  }
  cout << -1 << endl;
  return 0;
}

Submission Info

Submission Time
Task A - Equal Weight
User mitsuki_AC
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1629 Byte
Status
Exec Time 42 ms
Memory 17408 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt
All 300 / 300 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, sample-01.txt, sample-02.txt
Case Name Status Exec Time Memory
01-01.txt 6 ms 15872 KB
01-02.txt 6 ms 15872 KB
01-03.txt 6 ms 15872 KB
01-04.txt 6 ms 15872 KB
01-05.txt 6 ms 15872 KB
01-06.txt 6 ms 15872 KB
01-07.txt 7 ms 15872 KB
01-08.txt 7 ms 15872 KB
01-09.txt 7 ms 15872 KB
01-10.txt 8 ms 15872 KB
01-11.txt 6 ms 15872 KB
01-12.txt 6 ms 15872 KB
01-13.txt 9 ms 15872 KB
01-14.txt 6 ms 15872 KB
01-15.txt 40 ms 17408 KB
01-16.txt 39 ms 17408 KB
01-17.txt 42 ms 17408 KB
01-18.txt 27 ms 16640 KB
01-19.txt 26 ms 16640 KB
sample-01.txt 6 ms 15872 KB
sample-02.txt 6 ms 15872 KB