UVA - 12100 Printer Queue
因为刚开始题目理解错了,误认为刚开始取出的任务是需要打印的任务,结果用不同的方法重写了N边都是WA,悲剧啊
后来好好看题看,其实很简单。。。重写后一边AC
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while(T--) { int n, site; int time = 0; deque<int> deq; cin >> n >> site; for(int i = 0; i < n; i++) { int t; cin >> t; deq.push_back(t); } while(1) { if(site==0 && deq.front()==*max_element(deq.begin(), deq.end())) { cout << ++time << endl; break; } if(deq.front()==*max_element(deq.begin(), deq.end())) { time++; site--; deq.pop_front(); } else { int t = deq.front(); deq.pop_front(); deq.push_back(t); site = site==0 ? deq.size()-1 : site-1; } } } return 0; }