Submission #60345135
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;int main(void){int n, m;cin >> n >> m;vector<int> aa(n), ans(m);vector<pair<int, int>> a(n), b(m);for(int i=0; i<n; i++){cin >> a[i].first;a[i].second = i;aa[i] = a[i].first;}for(int i=0; i<m; i++){cin >> b[i].first;b[i].second = i;}int min = *min_element(begin(aa), end(aa));sort(a.begin(), a.end());sort(b.begin(), b.end());/*
#include <bits/stdc++.h> using namespace std; int main(void){ int n, m; cin >> n >> m; vector<int> aa(n), ans(m); vector<pair<int, int>> a(n), b(m); for(int i=0; i<n; i++){ cin >> a[i].first; a[i].second = i; aa[i] = a[i].first; } for(int i=0; i<m; i++){ cin >> b[i].first; b[i].second = i; } int min = *min_element(begin(aa), end(aa)); sort(a.begin(), a.end()); sort(b.begin(), b.end()); /* for(int i=0; i<n; i++){ cout << a[i].first << " " << a[i].second << endl; } cout << endl; for(int i=0; i<m; i++){ cout << b[i].first << " " << b[i].second << endl; }*/ int pos = 0; int tmp = 10000000; for(int i=0; i<m; i++){ ans[b[i].second] = tmp; if(b[i].first < min){ ans[b[i].second] = -1; continue; } for(int j=pos; j<n; j++){ if(b[i].first < a[j].first) continue; if(ans[b[i].second] == tmp){ if(j != m-1 && b[j].first == b[j+1].first){ pos = j; }else{ pos = j + 1; } } if(ans[b[i].second] > a[j].second + 1){ ans[b[i].second] = a[j].second + 1; } //cout << a[j].second << " " << b[j].second << endl; //cout << a[j].second + 1 << endl; //if(i != m-1 && b[i] != b[i+1]) } } for(int i=0; i<m; i++){ cout << ans[i] << endl; } }
Submission Info
Submission Time | |
---|---|
Task | C - Kaiten Sushi |
User | soraman |
Language | C++ 20 (gcc 12.2) |
Score | 0 |
Code Size | 1663 Byte |
Status | WA |
Exec Time | 2208 ms |
Memory | 8072 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 350 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3492 KB |
00_sample_01.txt | AC | 1 ms | 3476 KB |
00_sample_02.txt | AC | 1 ms | 3492 KB |
01_random_00.txt | TLE | 2207 ms | 5068 KB |
01_random_01.txt | WA | 1137 ms | 4128 KB |
01_random_02.txt | TLE | 2207 ms | 6312 KB |
01_random_03.txt | TLE | 2208 ms | 7488 KB |
01_random_04.txt | TLE | 2207 ms | 5740 KB |
02_random2_00.txt | TLE | 2208 ms | 8028 KB |
02_random2_01.txt | TLE | 2207 ms | 7940 KB |
02_random2_02.txt | TLE | 2208 ms | 7992 KB |
02_random2_03.txt | TLE | 2208 ms | 8000 KB |
02_random2_04.txt | TLE | 2208 ms | 7992 KB |
02_random2_05.txt | TLE | 2208 ms | 7916 KB |
02_random2_06.txt | TLE | 2208 ms | 7932 KB |
02_random2_07.txt | TLE | 2208 ms | 8064 KB |
02_random2_08.txt | TLE | 2208 ms | 7912 KB |
02_random2_09.txt | TLE | 2208 ms | 7996 KB |
02_random2_10.txt | TLE | 2208 ms | 7940 KB |
02_random2_11.txt | TLE | 2208 ms | 7996 KB |
02_random2_12.txt | TLE | 2208 ms | 7948 KB |
02_random2_13.txt | TLE | 2208 ms | 7988 KB |
02_random2_14.txt | TLE | 2208 ms | 7992 KB |
02_random2_15.txt | TLE | 2208 ms | 8052 KB |
02_random2_16.txt | TLE | 2208 ms | 7932 KB |
03_handmade_00.txt | TLE | 2208 ms | 8072 KB |
03_handmade_01.txt | TLE | 2208 ms | 7996 KB |
03_handmade_02.txt | AC | 220 ms | 5564 KB |
03_handmade_03.txt | AC | 220 ms | 5604 KB |
03_handmade_04.txt | AC | 1 ms | 3424 KB |